摘要:
Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the fol... 阅读全文
摘要:
Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi... 阅读全文
摘要:
Given two stringssandt, write a function to determine iftis an anagram ofs.For example,s= "anagram",t= "nagaram", return true.s= "rat",t= "car", retur... 阅读全文
摘要:
Implementint sqrt(int x).Compute and return the square root ofx.思路: 突然发现,二分真TM的是万能的。还有牛顿迭代法,数学的东西,头疼不想看了。还有传说中的“魔数”法,比math库效率都高,试了下RE - -。C++: 1 clas... 阅读全文
摘要:
Implement pow(x,n).思路: 实现pow(x,n)函数。首先,可以n次连乘x,但是这样太慢了。加速:2^10 -> 4^5 -> 16^2 * 4 ->256^1 * 4C++: 1 class Solution { 2 public: 3 double myPow(dou... 阅读全文
摘要:
Implement a basic calculator to evaluate a simple expression string.The expression string contains onlynon-negativeintegers,+,-,*,/operators and empty... 阅读全文
摘要:
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. Th... 阅读全文
摘要:
Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.题意: 实现除法,但不允许用乘、除、以及取模运算。思路: 一下一下减必然显得... 阅读全文
摘要:
Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted in asc... 阅读全文
摘要:
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord... 阅读全文