摘要: 3SumGiven an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:El... 阅读全文
posted @ 2014-07-08 19:38 陆草纯 阅读(4531) 评论(0) 推荐(0) 编辑
摘要: int转string(注:itoa不是标准函数,OJ平台可能不接受)int n = 10;char temp[32];string str; sprintf(temp, "%d", n);str = temp;orstring str = to_string(n);注意:to_string(int ... 阅读全文
posted @ 2014-07-08 11:08 陆草纯 阅读(290) 评论(0) 推荐(0) 编辑
摘要: Sudoku SolverWrite a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that the... 阅读全文
posted @ 2014-07-06 18:45 陆草纯 阅读(7401) 评论(3) 推荐(1) 编辑
摘要: Max Points on a LineGivennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.点和方向确定一条直线。需要两重循环,第一重循环遍历起始点a,第二重... 阅读全文
posted @ 2014-07-04 20:41 陆草纯 阅读(2017) 评论(1) 推荐(1) 编辑
摘要: Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root ... 阅读全文
posted @ 2014-06-26 23:34 陆草纯 阅读(293) 评论(0) 推荐(0) 编辑
摘要: Word Break IIGiven a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Retur... 阅读全文
posted @ 2014-06-26 22:35 陆草纯 阅读(2282) 评论(0) 推荐(0) 编辑
摘要: Simplify PathGiven an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"click to sh... 阅读全文
posted @ 2014-06-11 20:57 陆草纯 阅读(1489) 评论(0) 推荐(0) 编辑
摘要: Restore IP AddressesGiven a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"255255... 阅读全文
posted @ 2014-06-10 19:38 陆草纯 阅读(3636) 评论(4) 推荐(0) 编辑
摘要: Single NumberGiven an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runti... 阅读全文
posted @ 2014-06-07 12:30 陆草纯 阅读(371) 评论(0) 推荐(0) 编辑
摘要: Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [... 阅读全文
posted @ 2014-06-05 23:40 陆草纯 阅读(445) 评论(0) 推荐(0) 编辑