题目链接:Set Matrix ZeroesGiven a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.Follow up:Did you use extra space?A straight forward...
More »
题目链接:Edit DistanceGiven 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 ...
More »
题目链接:Climbing StairsYou are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you ...
More »
题目链接:Sqrt(x)Implement int sqrt(int x).Compute and return the square root of x.这道题的要求是实现int sqrt(int x),即计算x的平方根。考虑二分,即先令l和r分别为1和x/2+1(x的平方根一定小于等于x/2+1),然后m等于(l+r)/2,不断...
More »
题目链接:Text JustificationGiven an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.You...
More »
题目链接:Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".这道题的要求是两个二进制字符串加法运算。简单的大数加法,只不过是二进制的。处理进位的时候,按...
More »
题目链接: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 digit is at the...
More »
二战期间,一支部队在森林中与敌军发生激战,最后两名士兵与部队失去了联系。这两名士兵之所以在激战中还能互相照顾、彼此不分,因为他们来自同一个小镇。他们在森林中艰难跋涉,互相鼓励和安慰。十多天过去了,他们仍未与部队联系上。幸运的是,他们打死了一只鹿,依靠鹿肉,又能度过几日了。也许是因为战争的原因,森林中的动物四散奔逃或被杀光,除了那只鹿...
More »