Microsoft Interview Question

Question 1: Check if a string, composed of various brackets/braces/parentheses, is valid.

Interview Answers

Anonymous

May 31, 2022

Stacks use a lot of memory compared to counters. How about integer counter to store the number of open parenthesis. Iterate over each character: if (character is open parenthesis) then add to counter if (character is close parenthesis) then subtract from counter Return (counter == 0)

Anonymous

Feb 10, 2022

Use a stack to keep track

23