Grouping is Good problem help contest codeoverflow 1.0

I don’t know what’s wrong with this code why it is giving WA I tried manual test cases and it passes but getting WA in judge can someone give me one test case where this code will fail.
My idea is to increment a cnt variable if the occurrence of a particular number is odd else decrement by one if it is even and insert it to a vector. Then at the end take the first occurrence of a number and last and take the max difference.

My submission link: