[Leetcode : 452. Minimum Number of Arrows to Burst Balloons (Medium)](https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/description/)
[452. Minimum Number of Arrows to Burst Balloons (Medium)](https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/description/)
```
Input:
...
...
@@ -492,7 +492,7 @@ public int findMinArrowShots(int[][] points) {
@@ -738,7 +738,7 @@ public boolean hasCycle(ListNode head) {
**最长子序列**
[Leetcode : 524. Longest Word in Dictionary through Deleting (Medium)](https://leetcode.com/problems/longest-word-in-dictionary-through-deleting/description/)
[524. Longest Word in Dictionary through Deleting (Medium)](https://leetcode.com/problems/longest-word-in-dictionary-through-deleting/description/)
@@ -2969,7 +2969,7 @@ public int uniquePaths(int m, int n) {
**矩阵的最小路径和**
[Leetcode : 64. Minimum Path Sum (Medium)](https://leetcode.com/problems/minimum-path-sum/description/)
[64. Minimum Path Sum (Medium)](https://leetcode.com/problems/minimum-path-sum/description/)
```html
[[1,3,1],
...
...
@@ -3000,7 +3000,7 @@ public int minPathSum(int[][] grid) {
**需要冷却期的股票交易**
[Leetcode : 309. Best Time to Buy and Sell Stock with Cooldown(Medium)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/description/)
[309. Best Time to Buy and Sell Stock with Cooldown(Medium)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/description/)
题目描述:交易之后需要有一天的冷却时间。
...
...
@@ -3028,7 +3028,7 @@ public int maxProfit(int[] prices) {
**需要交易费用的股票交易**
[Leetcode : 714. Best Time to Buy and Sell Stock with Transaction Fee (Medium)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/description/)
[714. Best Time to Buy and Sell Stock with Transaction Fee (Medium)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/description/)
```html
Input: prices = [1, 3, 2, 8, 4, 9], fee = 2
...
...
@@ -3066,7 +3066,7 @@ public int maxProfit(int[] prices, int fee) {
**买入和售出股票最大的收益**
[Leetcode : 121. Best Time to Buy and Sell Stock (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/)
[121. Best Time to Buy and Sell Stock (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/)
只进行一次交易。
...
...
@@ -3088,7 +3088,7 @@ public int maxProfit(int[] prices) {
[Leetcode : 462. Minimum Moves to Equal Array Elements II (Medium)](https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/description/)
[462. Minimum Moves to Equal Array Elements II (Medium)](https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/description/)
```html
Input:
...
...
@@ -3452,7 +3452,7 @@ private void swap(int[] nums, int i, int j) {
**数组中出现次数多于 n / 2 的元素**
[Leetcode : 169. Majority Element (Easy)](https://leetcode.com/problems/majority-element/description/)
[169. Majority Element (Easy)](https://leetcode.com/problems/majority-element/description/)
先对数组排序,最中间那个数出现次数一定多于 n / 2。
...
...
@@ -3480,7 +3480,7 @@ public int majorityElement(int[] nums) {
For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0].
...
...
@@ -4152,7 +4152,7 @@ public void moveZeroes(int[] nums) {
**调整矩阵**
[Leetcode : 566. Reshape the Matrix (Easy)](https://leetcode.com/problems/reshape-the-matrix/description/)
[566. Reshape the Matrix (Easy)](https://leetcode.com/problems/reshape-the-matrix/description/)
```html
Input:
...
...
@@ -4184,7 +4184,7 @@ public int[][] matrixReshape(int[][] nums, int r, int c) {
**找出数组中最长的连续 1**
[Leetcode : 485. Max Consecutive Ones (Easy)](https://leetcode.com/problems/max-consecutive-ones/description/)
[485. Max Consecutive Ones (Easy)](https://leetcode.com/problems/max-consecutive-ones/description/)
```java
publicintfindMaxConsecutiveOnes(int[]nums){
...
...
@@ -4199,7 +4199,7 @@ public int findMaxConsecutiveOnes(int[] nums) {
**一个数组元素在 [1, n] 之间,其中一个数被替换为另一个数,找出丢失的数和重复的数**
[Leetcode : 645. Set Mismatch (Easy)](https://leetcode.com/problems/set-mismatch/description/)
[645. Set Mismatch (Easy)](https://leetcode.com/problems/set-mismatch/description/)
```html
Input: nums = [1,2,2,4]
...
...
@@ -4236,12 +4236,12 @@ private void swap(int[] nums, int i, int j) {
类似题目:
-[Leetcode :448. Find All Numbers Disappeared in an Array (Easy)](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/description/),寻找所有丢失的元素
-[Leetcode : 442. Find All Duplicates in an Array (Medium)](https://leetcode.com/problems/find-all-duplicates-in-an-array/description/),寻找所有重复的元素。
-[448. Find All Numbers Disappeared in an Array (Easy)](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/description/),寻找所有丢失的元素
-[442. Find All Duplicates in an Array (Medium)](https://leetcode.com/problems/find-all-duplicates-in-an-array/description/),寻找所有重复的元素。
**找出数组中重复的数,数组值在 [1, n] 之间**
[Leetcode : 287. Find the Duplicate Number (Medium)](https://leetcode.com/problems/find-the-duplicate-number/description/)
[287. Find the Duplicate Number (Medium)](https://leetcode.com/problems/find-the-duplicate-number/description/)
要求不能修改数组,也不能使用额外的空间。
...
...
@@ -4283,7 +4283,7 @@ public int findDuplicate(int[] nums) {
**有序矩阵查找**
[Leetocde : 240. Search a 2D Matrix II (Medium)](https://leetcode.com/problems/search-a-2d-matrix-ii/description/)
[240. Search a 2D Matrix II (Medium)](https://leetcode.com/problems/search-a-2d-matrix-ii/description/)
```html
[
...
...
@@ -4309,7 +4309,7 @@ public boolean searchMatrix(int[][] matrix, int target) {
**有序矩阵的 Kth Element**
[Leetcode : 378. Kth Smallest Element in a Sorted Matrix ((Medium))](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/description/)
[378. Kth Smallest Element in a Sorted Matrix ((Medium))](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/description/)
```html
matrix = [
...
...
@@ -4375,7 +4375,7 @@ class Tuple implements Comparable<Tuple> {
**数组相邻差值的个数**
[Leetcode : 667. Beautiful Arrangement II (Medium)](https://leetcode.com/problems/beautiful-arrangement-ii/description/)
[667. Beautiful Arrangement II (Medium)](https://leetcode.com/problems/beautiful-arrangement-ii/description/)
```html
Input: n = 3, k = 2
...
...
@@ -4403,7 +4403,7 @@ public int[] constructArray(int n, int k) {
**数组的度**
[Leetcode : 697. Degree of an Array (Easy)](https://leetcode.com/problems/degree-of-an-array/description/)
[697. Degree of an Array (Easy)](https://leetcode.com/problems/degree-of-an-array/description/)
```html
Input: [1,2,2,3,1,4,2]
...
...
@@ -4442,7 +4442,7 @@ public int findShortestSubArray(int[] nums) {
[Leetcode : 669. Trim a Binary Search Tree (Easy)](https://leetcode.com/problems/trim-a-binary-search-tree/description/)
[669. Trim a Binary Search Tree (Easy)](https://leetcode.com/problems/trim-a-binary-search-tree/description/)
```html
Input:
...
...
@@ -5173,7 +5173,7 @@ public TreeNode trimBST(TreeNode root, int L, int R) {
**从有序数组中构造二叉查找树**
[Leetcode : 108. Convert Sorted Array to Binary Search Tree (Easy)](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/description/)
[108. Convert Sorted Array to Binary Search Tree (Easy)](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/description/)
```java
publicTreeNodesortedArrayToBST(int[]nums){
...
...
@@ -5192,7 +5192,7 @@ private TreeNode toBST(int[] nums, int sIdx, int eIdx){
**两节点的最长路径**
[Leetcode : 543. Diameter of Binary Tree (Easy)](https://leetcode.com/problems/diameter-of-binary-tree/description/)
[543. Diameter of Binary Tree (Easy)](https://leetcode.com/problems/diameter-of-binary-tree/description/)
```html
Input:
...
...
@@ -5224,7 +5224,7 @@ private int depth(TreeNode root) {
**找出二叉树中第二小的节点**
[Leetcode : 671. Second Minimum Node In a Binary Tree (Easy)](https://leetcode.com/problems/second-minimum-node-in-a-binary-tree/description/)
[671. Second Minimum Node In a Binary Tree (Easy)](https://leetcode.com/problems/second-minimum-node-in-a-binary-tree/description/)
```html
Input:
...
...
@@ -5255,7 +5255,7 @@ public int findSecondMinimumValue(TreeNode root) {
**二叉查找树的最近公共祖先**
[Leetcode : 235. Lowest Common Ancestor of a Binary Search Tree (Easy)](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/description/)
[235. Lowest Common Ancestor of a Binary Search Tree (Easy)](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/description/)
[Leetcode : 236. Lowest Common Ancestor of a Binary Tree (Medium) ](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/description/)
[236. Lowest Common Ancestor of a Binary Tree (Medium) ](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/description/)
[Leetcode : 109. Convert Sorted List to Binary Search Tree (Medium)](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/description/)
[109. Convert Sorted List to Binary Search Tree (Medium)](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/description/)