Test Case 0,1 Faling TimeLimit

Test case 0 and 1 are failing i cant think of a way to reduce time complexity.

@anubhavb11
Please see this
0(1) solution https://ide.codingblocks.com/s/200016