Skip to content

Commit c893393

Browse files
committed
Arrays Exported
1 parent bbc2888 commit c893393

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

0-Arrays/Arrays.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ class Solution {
315315
316316
---
317317
318+
### [136.](136-Single-Number/136-Single-Number.java) Simgle Number
319+
**<font color=#C8A1E6> Sort; HashMap </font>**
320+
321+
---
322+
318323
### [169.](169-Majority-Element/169-Majority-Element-Sort.java) Majority Element
319324
**<font color=#C8A1E6> Sort; HashMap </font>**
320325
@@ -357,7 +362,17 @@ _时间复杂度:O(n); 空间复杂度:O(n)_
357362
---
358363
359364
### 1481. Least Number of Unique Integers after K Removals
365+
**<font color=#C8A1E6> Sort; HashMap; Greedy </font>**
366+
367+
#### [解法一](1481-Least-Number-of-Unique-Integers-after-K-Removals/1481-Least-Number-of-Unique-Integers-after-K-Removals.cpp):Bucket Sort从较低出现频率的数字开始去除
368+
369+
因为需要最后Unique的Number最少,所以可以从出现频率最低的数字开始一个一个去除,直到不能再去除位置。可以用HashMap来保存每个数字出现的频率,再把所有频率排序(用C++的Map自动排序),然后从频率低到高一个一个减少数字,最后看还剩多少特殊的数字即可。
370+
371+
#### [解法二](1481-Least-Number-of-Unique-Integers-after-K-Removals/1481-Least-Number-of-Unique-Integers-after-K-Removals.java):直接排序
372+
373+
[参考](https://leetcode.com/problems/least-number-of-unique-integers-after-k-removals/discuss/686376/Simple-C%2B%2B-O(N-log-N)-VIDEO-SOL)
360374
375+
直接在记录频率的过程中把某出现频率对应的数字存进一个数组中,将数组排序,最后从低到高进行处理即可。
361376
362377
## <font color=#7F71D9>其他:</font>
363378
### 9. Palindrome Number
@@ -373,4 +388,4 @@ _时间复杂度:O(n); 空间复杂度:O(n)_
373388
**<font color=#C8A1E6> HashMap </font>**
374389
### 1464. Maximum Product of Two Elements in an Array
375390
### 1470. Shuffle the Array
376-
### 5453. Running Sum of 1d Array
391+
### 1480. Running Sum of 1d Array

0-Arrays/Arrays.pdf

169 KB
Binary file not shown.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ Notes, Codes and Ideas on LeetCode Problems
44

55
## Arrays
66

7-
- [x] Two Pointers: 26, 27, 88, 283, 905, 941, 986, 1089 1471
7+
- [x] Two Pointers: 21, 26, 27, 88, 283, 905, 941, 986, 1089, 1471
88

99
- [x] 简单遍历: 1, 448, 1299
1010

11-
- [x] Sort: 75, 169, 973, 977, 1051, 1465
11+
- [x] Sort: 75, 169, 973, 977, 1051, 1465, 1471, 1481
1212

13-
- [x] 其他:9, 344, 387, 414, 485, 1295, 1346, 1464 1470
13+
- [x] 其他:9, 136, 344, 387, 414, 485, 1295, 1346, 1464, 1470, 1480
1414

1515
## Binary Search
1616
- [x] 136, 278, 540
@@ -34,7 +34,7 @@ Notes, Codes and Ideas on LeetCode Problems
3434
- [x] Others: 206, 237, 707
3535

3636
## Math
37-
- [x] 231, 367, 1232
37+
- [x] 60, 231, 367, 1232
3838

3939
## Stack
4040
- [x] 402, 901, 1472

0 commit comments

Comments
 (0)