Pregunta de entrevista de Microsoft

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

Respuestas de entrevistas

Anónimo

31 may 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)

Anónimo

10 feb 2022

Use a stack to keep track

23