自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(236)
  • 收藏
  • 关注

原创 DP:segment string

Segment a long string into a set of valid words using a dictionary. Return the maximum number  of the subwords.此题出自facebook面试题。方法一:套用矩阵连乘积模型。复杂度O(N^3)int segmentString(string str, set dict){ //

2013-09-03 18:42:45 636

原创 递归将二叉树转换为双向链表

总体思路是递归,将二叉树转换为记录了头尾指针的双向链表,函数如下Void convertTreeToListHelp(TreeNode *root, TreeNode *&head, TreeNode *&tail){ Head = root; tail = root; If (!root) Return; TreeNode *pLeftHead = NULL; TreeNode

2013-09-03 16:17:11 633

原创 LeetCode_FirstMissingPositive

Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses consta

2013-07-22 09:34:24 526

原创 LeetCode_Permutation Sequence

The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213"

2013-06-30 20:55:27 468

原创 LeetCode_Combination Sum II

Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the c

2013-06-30 12:22:33 461

原创 LeetCode_Combination Sum

Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited

2013-06-30 11:32:12 454

原创 LeetCode_Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,

2013-06-30 10:28:54 454

原创 LeetCode_Word Ladder

Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediat

2013-06-29 20:17:01 479

原创 LeetCode_Wildcard Matching

Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover t

2013-06-28 18:03:20 409

原创 LeetCode_Jump Game II

Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal i

2013-06-28 15:54:11 432

原创 LeetCode_Permute II

Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1

2013-06-28 15:11:49 576

原创 LeetCode_Permute

Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].void DFS(vect

2013-06-28 15:04:07 549

原创 LeetCode_Rotate Image

You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?class Solution {public: void rotate(vector >

2013-06-28 14:51:21 464

原创 LeetCode_Can Jump

Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine i

2013-06-28 11:59:15 500

原创 LeetCode_Length Of Last Word

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is

2013-06-28 10:20:15 473

原创 LeetCode_Unique Path II

Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the

2013-06-27 23:45:50 482

原创 LeetCode_Unique Paths

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach th

2013-06-27 23:33:55 410

原创 LeetCode_Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100"class Solution {public: string addBinary(string a, string b) { // Start

2013-06-27 23:17:04 488

原创 LeetCode_Plus One

Given a number represented as an array of digits, plus one to the number.class Solution {public: vector plusOne(vector &arr) { // Start typing your C/C++ solution below // DO NO

2013-06-27 22:49:10 495

原创 LeetCode_Sqrt

Implement int sqrt(int x).Compute and return the square root of x.class Solution {public: int sqrt(int x) { // Start typing your C/C++ solution below // DO NOT write i

2013-06-27 22:27:40 596

原创 Simplify Path

Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"Corner Cases:Did you consider the case w

2013-06-27 17:35:09 455

原创 LeetCode_Edit Distance

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a w

2013-06-27 16:21:49 421

原创 LeetCode_Set Matrix Zeros

Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.class Solution {public: void setZeroes(vector > &matrix) { // Start typing your C/C++ solu

2013-06-27 15:11:39 677

原创 LeetCode_Sort Colors

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integer

2013-06-27 15:03:31 395

原创 LeetCode_Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4

2013-06-27 11:29:10 379

原创 LeetCode_Gray Code

The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of

2013-06-27 10:34:06 408

原创 LeetCode_Decode Ways

A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total nu

2013-06-26 22:18:52 412

原创 LeetCode_Subsets II

Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain d

2013-06-26 21:11:50 394

原创 LeetCode_Reverse Linked List II

Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy

2013-06-26 20:24:10 421

原创 LeetCode Unique Binary Search Trees

Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1

2013-06-26 19:26:51 391

原创 LeetCode_Validate Binary Search Tree

Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's key.

2013-06-26 19:22:08 353

原创 LeetCode_ValidPalindrome

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is no

2013-06-26 19:19:44 396

原创 LeetCode_Interleaving String

Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc",

2013-06-26 19:11:32 364

原创 LeetCode_Restore IP Address

Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Orde

2013-06-26 19:03:18 424

转载 设计模式基础知识

下一步在设计模式方面的计划:巩固并运用设计模式,巩固:把《大话设计模式》,《.Net设计模式》,《设计模式——可复用的面向对象基础》,《敏捷软件开发:原则、模式与实践》这些书再结合起来系统的看一看,当然还会去买一些我手头上没有的关于设计模式的书;运用:部门前几天也提倡用C#来改版VB程序,我想这是一个很好的平台,正好有机会把理论的东西在实际中应用,理论加实际——唯一的学习方法。。。下面对各

2013-06-21 18:08:36 357

原创 CareerCup_1_7

Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0./* Write an algorithm such that if an element in an MxN matrix is 0, its entire row and co

2013-06-19 20:03:48 404

原创 CareerCup_1_6

Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?/* Given an image represented by an

2013-06-19 17:28:43 326

原创 CareerCup_1_4

Write a method to replace all spaces in a string with '%20'. You may assume that the string has sufficient space at the end of the string to hold the additional characters, and that you are give

2013-06-19 15:43:43 418

原创 CareerCup_1_1

Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures?/* Implement an algorithm to determine if a string has all unique charac

2013-06-19 10:49:57 419

转载 POSIX Threads Tutorial

OverviewThis is a brief tutorial on how write parallel applications using POSIX threads. Basically, this document is a short version of DEC's 300+ page manual; it is intended to provide sufficient i

2013-06-14 17:39:07 784

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除