题目:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthes....
分类:
编程语言 时间:
2014-07-31 02:41:15
阅读次数:
229
题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the neares....
分类:
编程语言 时间:
2014-07-31 02:30:25
阅读次数:
264
问题描述:
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
You should preserve the original relative order of the nodes in ...
分类:
其他好文 时间:
2014-07-30 12:21:33
阅读次数:
192
题目:Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3...
分类:
编程语言 时间:
2014-07-30 11:33:23
阅读次数:
258
题目:Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3...
分类:
编程语言 时间:
2014-07-30 09:54:33
阅读次数:
195
题目:Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,...
分类:
编程语言 时间:
2014-07-30 09:49:43
阅读次数:
177
定义一个队栈,每次出现一个数放进栈中,若出现运算符的话,就将栈顶的两个元素出栈进行运算后在放入栈考虑特殊情况1.只有一个数字的时候2.出现负数的情况class Solution{public: int evalRPN(vector &tokens) { // if(token...
分类:
其他好文 时间:
2014-07-30 07:40:03
阅读次数:
169
考虑几个特殊的情况1.若字符窜s=" "2.字符窜s=“a b d e”3.字符窜s=“ a”然后在s后面+上一个‘ ’,每次遇到s[i]为空格,s[i-1]不为空格的时候为一个单词class Solution{public: void reverseWords(string &s) ...
分类:
其他好文 时间:
2014-07-30 07:38:43
阅读次数:
171
Reverse Integer
java,python,C++三种代码练习
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
click to show s...
分类:
其他好文 时间:
2014-07-29 22:02:52
阅读次数:
333
问题描述:
Given an input string, reverse the string word by word.
For example,
Given s = "the sky is blue",
return "blue is sky the".
解题思路:
每遍历出一个单词时,将该单词添加一个空格字符(如果临时字符串为空,即扫描出第一个单词,就不要添加空格字符),然后添加...
分类:
其他好文 时间:
2014-07-29 21:52:52
阅读次数:
239