原创 Next Permutation

一. Next Permutation mplement next permutation, which rearranges numbers into the lexicographically next greater per

原创 Longest Common Prefix

一. Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. Dif

原创 二叉查找樹

一、LeetCode Medium Unique Binary Search Trees Unique Binary Search Trees II【TIMEOUT】 Validate Binary Search Tree Hard

原创 Unique Binary Search Trees

一. Unique Binary Search Trees Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?

原创 Pow(x, n)

一. Pow(x, n) Implement pow(x, n). Difficulty:Medium TIME:20MIN 解法一(遞歸) 這道題是求某個數的n次冪,按我們正常的思維來說,可能就是求n次乘法算得結果,時間複雜度爲O(n)

原创 Valid Number

一. Valid Number Validate if a given string is numeric. Some examples: “0” => true ” 0.1 ” => true “abc” => false

原创 Validate Binary Search Tree

一. Validate Binary Search Tree Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST i

原创 Unique Paths

一. Unique Paths A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The ro

原创 Spiral Matrix

一. Spiral Matrix Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral orde

原创 Maximal Rectangle

一. Maximal Rectangle Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s a

原创 Permutation Sequence

一. Permutation Sequence The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of

原创 Recover Binary Search Tree

一. Recover Binary Search Tree Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree witho

原创 Largest Rectangle in Histogram

一. Largest Rectangle in Histogram Given n non-negative integers representing the histogram’s bar height where the width

原创 Minimum Window Substring

一. Minimum Window Substring Given a string S and a string T, find the minimum window in S which will contain all the ch

原创 Scramble String

一. Scramble String Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrin