WA in first testcase of NOTALLFL

link to code : CodeChef: Practical coding for everyone

This is giving WA only for the first testcase. I am stuck here for more than a week . PLEASE HELP!
I have put comments in the code.
My approach:

storing the last index of the element, and also storing the freq of them. When the size of hashmap == k , i am removing the left element until the size < k and while removing, also decreasing the freq of that element. if during this, the freq becomes less than 1, it means that the element is no longer in the range left…right. So i remove it from both freq hashmap and hs hashmap

@admin3 You made this question… I don’t know what is the problem. Please help.

When k>n you are not inputting the sequence, so your input for the next case will be out of sync.

I can write a book on 100 dumb mistakes I made.

Thankyou very much!!!