CAST Group Interview Question

Parse brackets from a string.