Solution: https://ide.codingblocks.com/s/213117
what happening is if I am using sort function all the test cases are running fine except 0 and 1, and if I am not using sort function test cases 0 and 1 are right while all others are giving the wrong answer.