Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.
分类:
其他好文 时间:
2014-07-07 14:48:39
阅读次数:
160
Given a set of distinct integers, S, return all possible subsets.
分类:
其他好文 时间:
2014-07-07 14:31:24
阅读次数:
164
Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ],...
分类:
其他好文 时间:
2014-07-07 14:22:37
阅读次数:
210
Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="...
分类:
其他好文 时间:
2014-07-07 14:12:24
阅读次数:
204
参考Babylonian method(x0 越接近S的平方根越好)class Solution {public: int sqrt(double x) { if(x == 0) return 0; double root = x/2, tolerance = 1....
分类:
其他好文 时间:
2014-07-07 14:08:29
阅读次数:
173
题目:Merge Two Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the ...
分类:
其他好文 时间:
2014-07-07 14:06:19
阅读次数:
221
题目:Linked List Cycle IIGiven a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it withou...
分类:
其他好文 时间:
2014-07-07 13:44:29
阅读次数:
281
Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100". 1 class Solution 2 { 3 public: 4 ...
分类:
其他好文 时间:
2014-07-03 11:23:54
阅读次数:
164
这里笔者只写出关键代码:int add(int n,intm){ if(m==0) returnn; ① int sum=n^m; ② int carry=(n&m)<<1; ③ return add(sum,carry); ④} 在分析每步代码之前先看两个例子...
分类:
其他好文 时间:
2014-06-30 23:50:59
阅读次数:
428
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu...
分类:
其他好文 时间:
2014-06-30 21:36:50
阅读次数:
292