I particularly hate that question. Do you think that the optimal solution is something you can come up with during a regular 45 mins interview? I mean I understand the solution, but if I hadn't prepared, then I won't be able to come up with optimal solution in such a short time.
Same here. I cleared both Amazon and Microsoft. But if that was asked, I'd have been pissed.. I hate that question. It's not something that has an intuitive solution, or even worst, those index increments and decrements based on multiple conditions.. bwah.. I'll never ask that question in an interview. It only tests your retention, tower of hanoi