原创 LeetCode 刷題筆記之 全排列 in Java
題目如下:Given a collection of distinct integers, return all possible permutations.Example:Input: [1,2,3] Output: [ [1,2
原创 LeetCode 刷題筆記之 排高度
題目如下:Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k
原创 LeetCode 刷題筆記 之 迴文子串
題目如下:Given a string, your task is to count how many palindromic substrings in this string.The substrings with different
原创 LeetCode 刷題筆記 之 頻率最高的k個數(Top K Frequent Elements)
題目如下:Given a non-empty array of integers, return the k most frequent elements.For example,Given [1,1,1,2,2,3] and k = 2
原创 LeetCode 刷題筆記 之 Word Break
題目如下:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be s
原创 LeetCode 刷題筆記 之 Maximum Product Subarray
題目如下:Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which h
原创 LeetCode 刷題筆記 之 Lowest Common Ancestor of a Binary Tree
題目如下:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definit
原创 LeetCode 刷題筆記 之 Course Schedule
題目如下:There are a total of n courses you have to take, labeled from 0 to n-1.Some courses may have prerequisites, for ex
原创 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 n
原创 LeetCode 刷題筆記 之 Number of Islands
題目如下:Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water
原创 LeetCode 刷題筆記 之 Partition Equal Subset Sum
題目如下:Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets s
原创 LeetCode 刷題筆記 之 Maximal Square
題目如下:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.
原创 LeetCode 刷題筆記 之 Sort List
題目如下:Sort a linked list in O(n log n) time using constant space complexity.Example 1:Input: 4->2->1->3 Output: 1->2->3-
原创 LeetCode 刷題筆記 之 Convert BST to Greater Tree
題目如下:Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed
原创 LeetCode 刷題筆記 之 Best Time to Buy and Sell Stock with Cooldown
題目如下:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find