Bracket Validator using Objective-C

I have been asked the BracketValidator interview question twice now; It’s comparatively easy to formulate a Python/Java solution using the fancy data structures and built-in methods that Python/Java offers. So, I tried my hand solving this using Objective-C.

TL;DR: Solution can be found here.


In short, given a string containing brackets and parenthesis, every bracket opened i.e. ‘{‘, ‘(‘, ‘[‘ should have a corresponding closing bracket i.e. ‘}’, ‘)’, ‘]’. Note, the position of the closing bracket is important.

The following string will be valid:

But, the following won’t be correct:

A more apt description of the BracketValidator can be found here.

My github gist of the working solution can be found here.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s