2958. Length of Longest Subarray With at Most K Frequency - Medium
前往題目
想法
- 經典
Sliding window
思路
- 左右指針
- 每次循環移動右指針,更新右指針數字的數量
- 如果發現
invalid window
移動左指針直到window
為valid
- 更新
window
的大小
這次完整的自己寫出來一次AC
,而且花不到兩分鐘👍
Code
2958. Length of Longest Subarray With at Most K Frequency - Medium
https://f88083.github.io/2024/07/29/2958-Length-of-Longest-Subarray-With-at-Most-K-Frequency/