Question :find the kth missing element from left most in an array (4,7,9,14,15) k=3,output 8 missing=5,6,8,10,11,12,13
Intilally I have solved in an approach in few mins ,but it was not optimal and later I have been asked to optimize the both space & time complexity .I have solved the space complexity approach in 0(1) .And again interviewer asked to optimize the time complexity.I have told my scenario of optimizing the time complexity ,and he again asked me again to write code .
Overall I have written multiple approaches and improved my solution to optimize both time & space complexity each time.
Finally I have given an approach with optimal solution,but I couldn't able to code the last optimal solution as the time got consumed while discussing all the approaches to make solution as optimal.
And later he asked me some javascript questions which I answered most of them.
I request to all the interviewers first please consider how the candidate was making his efforts to make a solution as optimal or while giving the problem ,tell them you need a optimal solution in a specific time limit and give them some time to think to make a progress.