Getting TLE for O(N) solution...Please help

(topic deleted by author)