摘要:
Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After re... 阅读全文
摘要:
Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ... 阅读全文
摘要:
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a... 阅读全文
摘要:
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ... 阅读全文
摘要:
The string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font fo... 阅读全文
摘要:
Implement pow(x,n).题解:注意两点:普通的递归把n降为n-1会超时,要用二分的方法,每次把xn= x[n/2]* x[n/2] * xn-[n/2]*2, [n/2]表示n除以2下取整。n有可能取负数,负数的时候,先计算pow(x,-n),然后返回1/pow(x,-n);代码如下:... 阅读全文
摘要:
Given 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... 阅读全文
摘要:
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.题解:转换的方法:从左往右扫描罗马字符,如果当前的字符对应的数字比上一个数字小,就直接加... 阅读全文
摘要:
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.题解:基本的罗马字符和数字对应如下表所示:罗马字符数字I1V5X10L50C100D50... 阅读全文
摘要:
What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant extra space.For example,Given ... 阅读全文