摘要:
Implement pow(x,n).思路:像string to integer一样。考虑的细节较多。 1.测试用例要考虑基数和指数都为正数、负数和零的情况。 2.注意0的0次方在数学上没有意义。 3.考虑底数为0且指数为负数的处理方法。可以有返回值、全局变量和异常。这里使用全局变量区别... 阅读全文
摘要:
You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb... 阅读全文
摘要:
Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to... 阅读全文
摘要:
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t... 阅读全文