auto commit
This commit is contained in:
@ -16,7 +16,9 @@
|
||||
|
||||
# 1. 把数组中的 0 移到末尾
|
||||
|
||||
[283. Move Zeroes (Easy)](https://leetcode.com/problems/move-zeroes/description/)
|
||||
283\. Move Zeroes (Easy)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/move-zeroes/description/) / [力扣](https://leetcode-cn.com/problems/move-zeroes/description/)
|
||||
|
||||
```html
|
||||
For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0].
|
||||
@ -38,7 +40,9 @@ public void moveZeroes(int[] nums) {
|
||||
|
||||
# 2. 改变矩阵维度
|
||||
|
||||
[566. Reshape the Matrix (Easy)](https://leetcode.com/problems/reshape-the-matrix/description/)
|
||||
566\. Reshape the Matrix (Easy)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/reshape-the-matrix/description/) / [力扣](https://leetcode-cn.com/problems/reshape-the-matrix/description/)
|
||||
|
||||
```html
|
||||
Input:
|
||||
@ -74,7 +78,9 @@ public int[][] matrixReshape(int[][] nums, int r, int c) {
|
||||
|
||||
# 3. 找出数组中最长的连续 1
|
||||
|
||||
[485. Max Consecutive Ones (Easy)](https://leetcode.com/problems/max-consecutive-ones/description/)
|
||||
485\. Max Consecutive Ones (Easy)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/max-consecutive-ones/description/) / [力扣](https://leetcode-cn.com/problems/max-consecutive-ones/description/)
|
||||
|
||||
```java
|
||||
public int findMaxConsecutiveOnes(int[] nums) {
|
||||
@ -89,7 +95,9 @@ public int findMaxConsecutiveOnes(int[] nums) {
|
||||
|
||||
# 4. 有序矩阵查找
|
||||
|
||||
[240. Search a 2D Matrix II (Medium)](https://leetcode.com/problems/search-a-2d-matrix-ii/description/)
|
||||
240\. Search a 2D Matrix II (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/search-a-2d-matrix-ii/description/) / [力扣](https://leetcode-cn.com/problems/search-a-2d-matrix-ii/description/)
|
||||
|
||||
```html
|
||||
[
|
||||
@ -115,7 +123,9 @@ public boolean searchMatrix(int[][] matrix, int target) {
|
||||
|
||||
# 5. 有序矩阵的 Kth Element
|
||||
|
||||
[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))
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/description/) / [力扣](https://leetcode-cn.com/problems/kth-smallest-element-in-a-sorted-matrix/description/)
|
||||
|
||||
```html
|
||||
matrix = [
|
||||
@ -128,7 +138,9 @@ k = 8,
|
||||
return 13.
|
||||
```
|
||||
|
||||
解题参考:[Share my thoughts and Clean Java Code](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/discuss/85173)
|
||||
<EFBFBD><EFBFBD>题参考:[Share my thoughts and Clean Java Code
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/discuss/85173) / [力扣](https://leetcode-cn.com/problems/kth-smallest-element-in-a-sorted-matrix/discuss/85173)
|
||||
|
||||
二分查找解法:
|
||||
|
||||
@ -181,7 +193,9 @@ class Tuple implements Comparable<Tuple> {
|
||||
|
||||
# 6. 一个数组元素在 [1, n] 之间,其中一个数被替换为另一个数,找出重复的数和丢失的数
|
||||
|
||||
[645. Set Mismatch (Easy)](https://leetcode.com/problems/set-mismatch/description/)
|
||||
645\. Set Mismatch (Easy)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/set-mismatch/description/) / [力扣](https://leetcode-cn.com/problems/set-mismatch/description/)
|
||||
|
||||
```html
|
||||
Input: nums = [1,2,2,4]
|
||||
@ -221,12 +235,18 @@ private void swap(int[] nums, int i, int j) {
|
||||
|
||||
类似题目:
|
||||
|
||||
- [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/),寻找所有重复的元素。
|
||||
[448\. Find All Numbers Disappeared in an Array (Easy)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/description/),寻找所有丢失的元<E79A84>) / [力扣](https://leetcode-cn.com/problems/find-all-numbers-disappeared-in-an-array/description/),寻找所有丢失的元<E79A84>)
|
||||
[442\. Find All Duplicates in an Array (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/find-all-duplicates-in-an-array/description/),寻找所有重复的元素<E58583>) / [力扣](https://leetcode-cn.com/problems/find-all-duplicates-in-an-array/description/),寻找所有重复的元素<E58583>)
|
||||
|
||||
# 7. 找出数组中重复的数,数组值在 [1, n] 之间
|
||||
|
||||
[287. Find the Duplicate Number (Medium)](https://leetcode.com/problems/find-the-duplicate-number/description/)
|
||||
287\. Find the Duplicate Number (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/find-the-duplicate-number/description/) / [力扣](https://leetcode-cn.com/problems/find-the-duplicate-number/description/)
|
||||
|
||||
要求不能修改数组,也不能使用额外的空间。
|
||||
|
||||
@ -268,7 +288,9 @@ public int findDuplicate(int[] nums) {
|
||||
|
||||
# 8. 数组相邻差值的个数
|
||||
|
||||
[667. Beautiful Arrangement II (Medium)](https://leetcode.com/problems/beautiful-arrangement-ii/description/)
|
||||
667\. Beautiful Arrangement II (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/beautiful-arrangement-ii/description/) / [力扣](https://leetcode-cn.com/problems/beautiful-arrangement-ii/description/)
|
||||
|
||||
```html
|
||||
Input: n = 3, k = 2
|
||||
@ -296,7 +318,9 @@ public int[] constructArray(int n, int k) {
|
||||
|
||||
# 9. 数组的度
|
||||
|
||||
[697. Degree of an Array (Easy)](https://leetcode.com/problems/degree-of-an-array/description/)
|
||||
697\. Degree of an Array (Easy)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/degree-of-an-array/description/) / [力扣](https://leetcode-cn.com/problems/degree-of-an-array/description/)
|
||||
|
||||
```html
|
||||
Input: [1,2,2,3,1,4,2]
|
||||
@ -335,7 +359,9 @@ public int findShortestSubArray(int[] nums) {
|
||||
|
||||
# 10. 对角元素相等的矩阵
|
||||
|
||||
[766. Toeplitz Matrix (Easy)](https://leetcode.com/problems/toeplitz-matrix/description/)
|
||||
766\. Toeplitz Matrix (Easy)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/toeplitz-matrix/description/) / [力扣](https://leetcode-cn.com/problems/toeplitz-matrix/description/)
|
||||
|
||||
```html
|
||||
1234
|
||||
@ -373,7 +399,9 @@ private boolean check(int[][] matrix, int expectValue, int row, int col) {
|
||||
|
||||
# 11. 嵌套数组
|
||||
|
||||
[565. Array Nesting (Medium)](https://leetcode.com/problems/array-nesting/description/)
|
||||
565\. Array Nesting (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/array-nesting/description/) / [力扣](https://leetcode-cn.com/problems/array-nesting/description/)
|
||||
|
||||
```html
|
||||
Input: A = [5,4,0,3,1,6,2]
|
||||
@ -407,7 +435,9 @@ public int arrayNesting(int[] nums) {
|
||||
|
||||
# 12. 分隔数组
|
||||
|
||||
[769. Max Chunks To Make Sorted (Medium)](https://leetcode.com/problems/max-chunks-to-make-sorted/description/)
|
||||
769\. Max Chunks To Make Sorted (Medium)
|
||||
|
||||
[Leetcode](https://leetcode.com/problems/max-chunks-to-make-sorted/description/) / [力扣](https://leetcode-cn.com/problems/max-chunks-to-make-sorted/description/)
|
||||
|
||||
```html
|
||||
Input: arr = [1,0,2,3,4]
|
||||
|
Reference in New Issue
Block a user