Round 1
Questions:
-
Valid parenthesis - was able to answer using stack based approach
Eg. "{(){}[]}" - valid ; "){}(" - invalid -
Give the result string after minimum add to make parentheses string valid - was able to give approach to create valid string but not able to form minimum steps logic. IMO, we can get multiple answers also so this should involve dynamic programming.
Note: The string has 3 types of parentheses '(', '{', and '[', so the greedy solution will not work.
Eg. "(){([)}()" -> "(){([])}()"
"([)]" -> "([()])" or "()[()]"
Candidate's Approach
- For the first question, the candidate successfully utilized a stack-based approach to determine if the parentheses were valid.
- For the second question, the candidate proposed an approach to create a valid string but struggled with the logic for determining the minimum steps required. They suggested that dynamic programming might be necessary due to the potential for multiple valid outputs.
Interviewer's Feedback
No feedback provided.