Why it is showing me tle the code has take only O(n) time

I have edited your code… I have made a bool function… Try to submit it now…