Here is the problem link: https://www.codechef.com/LTIME81B/problems/NOTALLFL
This is my code: https://ide.geeksforgeeks.org/V23I9WsQXT
My idea is to store the starting and ending indices of each flavour and then try excluding each one of them. Excluding each of them by getting all the flavours from the beginning to the first occurrence of it and compare it with getting all the flavours from the ending to the last occurrence of it, the greater of these will be stored and compared to the greater of the other flavours.
Initially I tried to exclude the flavour who’s starting and ending indices were the closest, but I realized it was wrong as it failed in the below case:
1 2 1 2 1 2 4 3 3 1
So, I ended up excluding all of them but it still gives a WA.
Please point out the flaw in my logic and/or my code. Thanks in advance!