Can anyone explain atcoder problem logic

3rd question colorfully candies

Learn Sliding Window. You can watch Aditya Verma Sliding Window playlist on youtube.

1 Like

bro can you tell me what is wrong with my code
It passed 11 tc and failed in 13 tc.

@goshika

you are not applying the sliding window technique;

think about these line why you are writing this
long long x = mp.size();
result = max(result,x);

you have to keep track of exactly K size of the subarray in each iteration.

you can see my solution Colorful Candies

1 Like