摘要:
Valid NumberValidate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended for the ... 阅读全文
摘要:
Plus OneGiven a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant dig... 阅读全文
摘要:
Text JustificationGiven an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) just... 阅读全文
摘要:
Sqrt(x)Implementint sqrt(int x).Compute and return the square root ofx.解法一:牛顿迭代法求n的平方根,即求f(x)=x2-n的零点设初始值为x0,注,不要设为0,以免出现除数为0,见后。则过(x0,f(x0))点的切线为g(x)... 阅读全文
摘要:
Edit DistanceGiven two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You... 阅读全文
摘要:
Set Matrix ZeroesGiven amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you us... 阅读全文
摘要:
Minimum Window SubstringGiven a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).Fo... 阅读全文
摘要:
1、计数排序如果给定上下界,并且区间不大的话,最适用。比如对于英文字母数组进行排序。时间复杂度O(n),空间复杂度O(n)void countSort(int A[], int n, int low, int high){ int size = high-low+1; vector co... 阅读全文
摘要:
CombinationsGiven two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3... 阅读全文
摘要:
Search in Rotated Sorted Array IIFollow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity... 阅读全文