Rotate an array of n elements to the right by k steps.For example, with n=7n = 7 and k=3k = 3, the array [1,2,3,4,5,6,7][1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4][5,6,7,1,2,3,4].Note:
Try to come u...
分类:
其他好文 时间:
2015-02-24 18:44:30
阅读次数:
164
Rotate an array ofnelements to the right byksteps.For example, withn= 7 andk= 3, the array[1,2,3,4,5,6,7]is rotated to[5,6,7,1,2,3,4].Note:Try to come...
分类:
编程语言 时间:
2015-02-24 16:19:43
阅读次数:
4707
题目Given 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).For example,
S = “ADOBECODEBANC”
T = “ABC”
Minimum window is “BANC”.Note...
Given a binary tree, return the postorder traversal of its nodes’ values.For example:
Given binary tree {1,#,2,3},
return [3,2,1].Note: Recursive solution is trivial, could you do it iteratively?...
分类:
其他好文 时间:
2015-02-24 07:02:03
阅读次数:
180
Given a binary tree, return the preorder traversal of its nodes’ values.For example:
Given binary tree {1,#,2,3},
return [3,2,1].Note: Recursive solution is trivial, could you do it iteratively?递归...
分类:
其他好文 时间:
2015-02-24 01:53:20
阅读次数:
192
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is ...
分类:
其他好文 时间:
2015-02-23 15:26:34
阅读次数:
168
Say you have an array for which the ithi^{th} element is the price of a given stock on day ii.Design an algorithm to find the maximum profit. You may complete at most k transactions.Note:
You may not...
分类:
其他好文 时间:
2015-02-23 00:16:37
阅读次数:
174
Say you have an array for which the ithi^{th} element is the price of a given stock on day ii.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:
You may no...
分类:
其他好文 时间:
2015-02-22 18:31:15
阅读次数:
181
Problem:
Given two numbers represented as strings, return multiplication of the numbers as a string.
Note: The numbers can be arbitrarily large and are non-negative.
Solution:
multiply...
分类:
其他好文 时间:
2015-02-22 14:38:15
阅读次数:
101
Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
分类:
其他好文 时间:
2015-02-22 06:46:02
阅读次数:
162