Pergunta de entrevista da empresa Bloomberg

They asked to write a program that could identify if the delimiters in a string were balanced

Resposta da entrevista

Sigiloso

5 de jan. de 2025

I used a stack based approach iterating over each character in the string and checking if it was a closing or opening delimiter it was an opening delimiters I pushed it onto the stack of was a closing I popped items off the stack until I found the corresponding opening delimiter. If it existed I continued iterating if not the string was unbalanced