Round 1
Questions:
-
1249. Minimum Remove to Make Valid Parentheses
I coded it using a stack solution first. Follow-up was to code without stack. The interviewer wanted O(1) space complexity which wasn't really possible because of Python but I explained a solution without using stack and they were okay with it. -
- Lowest Common Ancestor of a Binary Tree III
The exact same question but the example used letters instead of numbers. Gave them an optimal solution with O(1) space. Didn't brute force cause time was running out since I had to rewrite code for the first one. Interviewer was satisfied.
- Lowest Common Ancestor of a Binary Tree III
Candidate's Approach
- For the first question, I initially implemented a stack-based solution. When asked for an O(1) space complexity solution, I explained an alternative approach without using a stack, which the interviewer accepted.
- For the second question, I provided an optimal solution with O(1) space, but I had to manage my time carefully and couldn't brute force due to time constraints.
Interviewer's Feedback
The interviewer noted a bug in my first code, which I corrected. Although my explanation for the second question wasn't great, they acknowledged that my solution was acceptable and understood my approach.