-
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The left subtr...
-
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The left subtr...
-
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.
Example 1:
12Input: s1 = "aabcc", s2 ...
-
Reverse a linked list from position m to n. Do it in one-pass.
Note: 1 ≤ m ≤ n ≤ length of list.
Example:
12Input: 1->2-&g...
-
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).
You may assume that ...
-
Given an unsorted integer array, find the smallest missing positive integer.
Example 1:
12Input: [1,2,0]Output: 3
Example 2:...
-
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
For example,Given th...
-
Write a program to find the nth super ugly number.
Super ugly numbers are positive numbers whose all prime factors are in the...
-
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
(i.e., [0,0,1,2,2,5,6] might b...
-
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....