Skip to content

Commit

Permalink
Create Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wisdompeak authored Nov 7, 2022
1 parent 48c9b62 commit 800a37b
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
### 2461.Maximum-Sum-of-Distinct-Subarrays-With-Length-K

非常普通的固定长度的滑窗。

用一个HashMap来记录每个number出现的次数。用count来表示滑窗内的distinct number的数量。count的变动依据如下:
1. 当新加入一个数字时
```cpp
Map[num]++;
if (Map[num]==1)
count++;
```
2. 当移出一个数字时
```cpp
Map[num]--;
if (Map[num]==0)
count--;
```

0 comments on commit 800a37b

Please sign in to comment.