correct ans with O(N) complexity but still shows error.
hey @yashikakhurana00, increase the size of array to 100005.