Balanced Delimiters
June 10, 2014
I heard today’s exercise as an interview question — you have five minutes to solve this task, while I watch — but it could equally be a homework problem:
Write a function to return true/false after looking at a string. Examples of strings that pass:
{}, [], (), a(b)c, abc[d], a(b)c{d[e]}
Examples of strings that don’t pass:
{], (], a(b]c, abc[d}, a(b)c{d[e}]
Your task is to write the function described above. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below: