Can you tell my how my approach is wrong.
Problem: RECNDROT Problem - CodeChef
My answer:CodeChef: Practical coding for everyone
Its a O(n) solution.
Can you give me one example where it goes wrong.
Can you tell my how my approach is wrong.
Problem: RECNDROT Problem - CodeChef
My answer:CodeChef: Practical coding for everyone
Its a O(n) solution.
Can you give me one example where it goes wrong.
1
4
1 3 2 3
Your code outputs 2, whereas ans is 1.
Also, your time complexity is O(N*log(N)), because inserting each element takes logN time in map and you are doing it N times.
Thanks for your help