Faaaahhhh
1 experiences · Other (1)
Faaaahhhh moment for my current level in DSA !!!
Interview Experience
The question was "Check if array is Sorted and Rotated" (q no- 1752)... 1. first applied brute force (sort the array O(n\^2) + checking the array in every rotation O(n\^2) ) 2. In the mid of brute force , the drop concept clicked me, i.e If a sorted array is really rotated by some steps there must be a drop between last element and first element somewhere in the input array. 3. Analyzed the behaviour and dropping values in array. 4. After 15-20 times running the code, 5-6 failed testcases. Finally after performing dry run(actually fry run), saw that simply I have to check if the value of drop is 0 or 1 after complete rotation, if yes return true else false. It took nearly 4 hrs to crack the whole problem.🙂🥲 for reference https://preview.redd.it/fswagzb7l9og1.png?width=1919&format=png&auto=webp&s=2758738e1a4b54e3407b9ba69e97727857e5a82f idk why but I laughed after seeing "Accepted" !!! One more thing guys, This is the first time I am posting a content like this in any platform. So any suggestions will be helpful for my future posts.