原创 Leetcode 300.longest-increasing-subsequence
method 1 dp 使用動態規劃,dp[i]代表以第i個數結尾時的最大長度 //dp[i]表示以num[i]結尾的序列的最大長度 int lengthOfLIS(vector<int>& nums) { if (nums.s
原创 Leetcode 324. Wiggle Sort II
Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]… Example 1: Input: nums =
原创 Leetcode array Top Interview Questions 32道題總結
本篇文章是對leetcode array和Top Interview Questions標籤下32道array類型題目的總結 leetcode 283. Move Zeroes 此題屬於數組交換型,交換數組中元素的位置以滿足某種條
原创 Leetcode 46/47/31/60 Permutations 專題
Leetcode 46 Permutations Given a collection of distinct integers, return all possible permutations. Example: Input:
原创 Leetcode 127. Word Ladder
Given two words (beginWord and endWord), and a dictionary’s word list, find the length of shortest transformation s
原创 Leetcode 108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem,
原创 Leetcode 98. Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The l
原创 leetcode 344. Reverse String
Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocat
原创 Leetcode 130. Surrounded Regions
Given a 2D board containing ‘X’ and ‘O’ (the letter O), capture all regions surrounded by ‘X’. A region is captured
原创 Leetcode 140. Word Break II
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to const
原创 Leetcode 207/210. Course Schedule I/II
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 200. 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 350. Intersection of Two Arrays II
Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2
原创 Leetcode 17. Letter Combinations of a Phone Number
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could
原创 116/117. Populating Next Right Pointers in Each Node I/II
先看116 Given a binary tree struct Node { int val; Node *left; Node *right; Node *next; } Populate each next pointer