Help rahul to search challenge


why am I getting TLE in seocnd test case?

hi apoorva,
your code is not working for the test case in which element is not present.
5
4 5 1 2 3 6
Try this test case.
Please let me know if you need any other help.

I still can’t figure a wayout to prevent TLE.

@apoorvas1301
Try approaching the question in a different way. Your current solution is unable to handle sorted arrays.
Try approaching it this way: find the pivot. Then the key must either lie to the left of pivot which is a sorted array or the key must lie to the right of pivot which again is a sorted array. Thus the entire problem boils down to locating the pivot.

If my answer is able to answer your query, please mark the doubt as resolved.