Given an input string, reverse the string word by word.For example,
Given s = “the sky is blue”,
return “blue is sky the”.Update (2015-02-12):
For C programmers: Try to solve it in-place in O(1) s...
分类:
其他好文 时间:
2015-05-06 00:01:27
阅读次数:
188
Remove all elements from a linked list of integers that have value val.Example
Given: 1 –> 2 –> 6 –> 3 –> 4 –> 5 –> 6, val = 6
Return: 1 –> 2 –> 3 –> 4 –> 5...
分类:
其他好文 时间:
2015-05-02 09:37:29
阅读次数:
119
Given inorder and postorder traversal of a tree, construct the binary tree.Note:
You may assume that duplicates do not exist in the tree....
分类:
其他好文 时间:
2015-05-01 20:00:19
阅读次数:
188
Given preorder and inorder traversal of a tree, construct the binary tree.Note:
You may assume that duplicates do not exist in the tree....
分类:
其他好文 时间:
2015-04-28 22:52:42
阅读次数:
199
一个整型数组里除了两个数字之外,其他的数字都出现了两次。请写程序找出这两个只出现一次的数字。思路我们直到异或的性质:任何一个数字异或他自己都等于0.
所以说我们如果从头到尾依次异或每一个数字,那么最终的结果刚好只出现一次的数字,因为成对出现的两次的数字全部在异或中抵消了。这道题中有两个数字只出现一次。这样的话我们得到的结果就是这两个数字的异或结果。因此我们想办法把原数组分成两个子数组,使得每个子...
分类:
编程语言 时间:
2015-04-26 19:47:36
阅读次数:
120
Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.For example, given the range [5, 7], you should return 4....
分类:
其他好文 时间:
2015-04-26 16:49:12
阅读次数:
120
题目Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.For “(()”, the longest valid parentheses substring is “()”, which h...
分类:
其他好文 时间:
2015-04-23 21:49:15
阅读次数:
156
Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of...
分类:
移动开发 时间:
2015-04-22 22:15:41
阅读次数:
1099
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Example...
分类:
其他好文 时间:
2015-04-22 18:34:17
阅读次数:
125
题目Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11’ has binary representation 00000000000...
分类:
其他好文 时间:
2015-04-12 21:12:01
阅读次数:
130