You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This discussion was converted from issue #82 on September 15, 2026 11:06.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Problem link
https://leetcode.com/problems/maximum-sum-of-almost-unique-subarray
Problem Summary
배열과 m, k가 주어질 때 배열의 subarray 중에서 길이가 k이고 중복되지 않는 수가 최소 m개인 개수를 구하는 문제.
Solution
딱 보니 간단한 슬라이딩 윈도우 문제이다.
배열의 처음부터 끝까지 죽 돌면서 길이가 k이고 중복되지 않는 수가 m개가 되도록 체크해주면 된다.
중복되는 수 체크는 map (dict)로 간단하게 할 수 있고 right는 개수 증가, left는 개수 감소를 해주면서 중복되지 않는 수가 몇개인지 계속 체크해주면서 슬라이딩 윈도우를 이동시키면 된다.
코드 자체는 생각보다 길긴 한데 어렵지 않다.
Source Code
All reactions