题目:
Given a binary tree, return the preorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,2,3].
Note: Recursive...
分类:
编程语言 时间:
2015-01-14 22:59:13
阅读次数:
174
Given an index k, return the kth row of the Pascal's triangle.
For example, given k = 3,
Return [1,3,3,1].
Note:
Could you optimize your algorithm to use only O(k) extra space?
class Solution...
分类:
其他好文 时间:
2015-01-14 22:57:33
阅读次数:
162
问题描述:
Given a list of non negative integers, arrange them such that they form the largest number.
For example, given [3, 30, 34, 5, 9], the largest formed number is
9534330.
Note: The result may...
分类:
其他好文 时间:
2015-01-14 21:28:06
阅读次数:
196
https://oj.leetcode.com/problems/binary-search-tree-iterator//**
*Definitionforbinarytree
*publicclassTreeNode{
*intval;
*TreeNodeleft;
*TreeNoderight;
*TreeNode(intx){val=x;}
*}
*/
publicclassBSTIterator{
//
//NOTE
//Aftertheiteratorbuilt,ifwemodifytheor..
分类:
其他好文 时间:
2015-01-14 18:17:56
阅读次数:
165
题目:
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.
Calling next() will return the next smallest number in the BST.
Note:...
分类:
编程语言 时间:
2015-01-14 18:01:28
阅读次数:
182
Follow up for problem "Populating Next Right Pointers in Each Node".
What if the given tree could be any binary tree? Would your previous solution still work?
Note:
You may only use constant ...
分类:
其他好文 时间:
2015-01-14 17:55:09
阅读次数:
199
题目
Given two sorted integer arrays A and B, merge B into A as one sorted array.
Note: You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements ...
分类:
其他好文 时间:
2015-01-14 16:54:36
阅读次数:
183
Given a string S, find the longest palindromic substring in S.
Note:
This is Part II of the article: Longest
Palindromic Substring. Here, we describe an algorithm (Manacher’s algorithm) which...
分类:
其他好文 时间:
2015-01-14 15:40:50
阅读次数:
326
Syntax:
#sed -e 'command' -e 'command' filename
Note: -e option is optional for sed with single command. sed will execute the each set of command while processing input from the pattern buffer.
...
分类:
其他好文 时间:
2015-01-14 15:35:56
阅读次数:
164
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 pretty straight forward. Could you devis...
分类:
其他好文 时间:
2015-01-14 09:53:16
阅读次数:
154