I have to give my one of the biggest interviews next week and I am working hard for that. I have also enrolled myself for some mock interviews for that. So, coming to the problem last day I had this mock interview and I was asked this question:
Search an element in a sorted and rotated array
at first I was clueless but the interviewer asked me to break the problem at hand and then solve the smaller problem first so I decided to write binary search to find the element in the sorted array, surprisingly I was able to write the algorithm within a go since I had clear mental model of the problem at hand now I was asked to proceed and solve the given question. I thought for a second and told him that if I somehow know the peak point I can decide which direction to go to find the given element, he told me that I am on the right track and then boom I wasn't able to think properly on how to convert my logic into code, he gave me a couple of hints and it was too embarrassing for me to just sit and think.
The problem is after knowing the solution and knowing that my intuition was correct I am not sure why I failed, I need to know is there a different way of thinking of such problems to better understand the logic? Why I feel discomfort when I found a new problem on binary search although I knew and solved the original one? is there a gap in my mental modal?