Problem
Given n, how many structurally unique BST’s (binary search trees) that store values 1 … n?
Example:
1 |
|
Given n, how many structurally unique BST’s (binary search trees) that store values 1 … n?
Example:
1 |
|
Given an integer n, generate all structurally unique BST’s (binary search trees) that store values 1 … n.
Example:
1 |
|
Given a binary tree, return the inorder traversal of its nodes’ values.
Example:
1 |
|
Follow up: Recursive solution is trivial, could you do it iteratively?
Given a string containing only digits, restore it by returning all possible valid IP address combinations.
Example:
1 |
|
Reverse a linked list from position m to n. Do it in one-pass.
Note: 1 ≤ m ≤ n ≤ length of list.
Example:
1 |
|
A message containing letters from A-Z
is being encoded to numbers using the following mapping:
1 |
|
Given a non-empty string containing only digits, determine the total number of ways to decode it.
Example 1:
1 |
|
Example 2:
1 |
|
Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).
Note: The solution set must not contain duplicate subsets.
Example:
1 |
|
The gray code is a binary numeral system where two successive values differ in only one bit.
Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0.
Example 1:
1 |
|
Example 2:
1 |
|
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
Note:
Example:
1 |
|
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.
Below is one possible representation of s1 = "great"
:
1 |
|
To scramble the string, we may choose any non-leaf node and swap its two children.
For example, if we choose the node "gr"
and swap its two children, it produces a scrambled string "rgeat"
.
1 |
|
We say that "rgeat"
is a scrambled string of "great"
.
Similarly, if we continue to swap the children of nodes "eat"
and "at"
, it produces a scrambled string "rgtae"
.
1 |
|
We say that "rgtae"
is a scrambled string of "great"
.
Given two strings s1 and s2 of the same length, determine if s2 is a scrambled string of s1.
Example 1:
1 |
|
Example 2:
1 |
|