My code for Lunchtime problem INCRDEC
https://www.codechef.com/viewsolution/34838601
My approach
- Firstly, I checked that elements of given array are unique or not if unique I print YES and print array in sorted order.
- If its not unique, I create a Map and update it on encounter frequency more then one and append that element in a new list.
- I sorted the hashmap and check about the max key, if value of max(key) is greater then 1 print NO.
- Same I checked the values of rest keys if values are greater then 2 I took a variable, initialize it by 0 and update it to 1.
- Finally I check if variable if 0 print YES and reversely sort the list which I create in map and mearge it with set.
please help me in finding my fault, please provide any testcase where my code going wrong.
Thanks