描述
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) spac
...
描述
Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level a
...
描述
Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).
F
...
描述
Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).
For example:Given binary tree
...
描述
Given a binary tree, return the postorder traversal of its nodes’ values.
For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3
...
描述
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
...
描述
Given a binary tree, return the preorder traversal of its nodes’ values.
For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,
...
描述
Evaluate the value of an arithmetic expression in Reverse Polish Notation.
Valid operators are +, -, *, /. Each operand may be an integer or anothe
...
描述
Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the h
...
描述
Given a string containing just the characters ‘(‘ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.
For “(()”, the
...
描述
Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the input string is valid.
The brackets must close in t
...
描述
Given a string s consists of upper/lower-case alphabets and empty space characters ‘ ‘, return the length of last word in the string.
If the last w
...
描述
Given an absolute path for a file (Unix-style), simplify it.
For example,path = “/home/“, => “/home”path = “/a/./b/../../c/“, => “/c”
Corner
...
描述
Given an array of strings, group anagrams together.
For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”],Return:
[ [“ate”, “eat”,”tea”],
...
描述
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, …
1 is read off as “one 1” or 11.11 is read of
...