Sir I am getting TLE in O(n) solution

I am getting TLE in 1 test case. What am i missing here ?

that’s because the input data is very large so you have to use scanf for reading input insead of cin as scanf is faster than cin

In case of any doubt feel free to ask :slight_smile:
if you got the answer mark your doubt as resoved

Sir i updated my code as per your suggestions. Its still stuck in TLE.

https://ide.codingblocks.com/s/186688 still having TLE

hey , there is a time precision issue in this problem try submitting your solution two three times it will pass all test cases ( your solution passes all test cases in my computer)