原创 LeetCode刷題筆錄Subsets II
Given a collection of integers that might contain duplicates, S, return all possible subsets. Note: Elements in a su
原创 LeetCode刷題筆錄Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example, Giv
原创 LeetCode刷題筆錄Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last wor
原创 LeetCode刷題筆錄Spiral Matrix
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example,
原创 LeetCode刷題筆錄N-Queens II
Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct sol
原创 LeetCode刷題筆錄Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palin
原创 LeetCode刷題筆錄Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do no
原创 LeetCode刷題筆錄Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative int
原创 LeetCode刷題筆錄Add Binary
Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 具體一位一
原创 LeetCode刷題筆錄Count and Say
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1 is read of
原创 LeetCode刷題筆錄Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 用一個priority queue,先
原创 LeetCode刷題筆錄Roman to Integer
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 和Integer
原创 LeetCode刷題筆錄Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. N
原创 LeetCode刷題筆錄Search in Rotated Sorted Array II
Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time comple
原创 LeetCode刷題筆錄Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a