Rishi_Kant's blog

By Rishi_Kant, history, 4 years ago, In English

Hi everyone, I am getting WA in codechef lunchtime priblem INCRDEC INCRDEC my code for this is code.

My approach

1.Firstly, I checked that elements of given array are unique or not if unique I print YES and print array in sorted order.

2.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.

3.I sorted the hashmap and check about the max key, if value of max(key) is greater then 1 print NO.

4.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.

5.Finally I check if variable if 0 print YES and reversely sort the list which I create in map and marge it with set.

please help me in finding my fault, please provide any testcase where my code going wrong. Thanks alot.

  • Vote: I like it
  • +2
  • Vote: I do not like it

| Write comment?