Playing Hacks and Stuffs!
I initially tried implementing binary search algorithm but I got to a test case where it wasn’t just working and i spent so many hours trying to fix it but didn’t succeed :(
So I moved to solving it using Linear Search
It works but the time and space complexity is low also you can see I was trying to solve it 2 hours ago but the last test case was not working 🥲
Solve Script: link
After checking the solution other people made I figured my mistake in my previous Binary Search program and I was totally over complicating it lool
Anyways here’s a more efficient script: link