Tag Archives: Algorithms

Matching braces in a string

I heard recently about an interview problem involving matching braces in a string. Checking to see if all the braces in a string are paired up in the proper order. Seemed like an interesting, and short, challenge.

Examples of strings with proper brace matching: "()", "(){}[]", "([{}])"

Examples of strings without proper brace matching: "(", "[]]", "([)]"

Continue reading Matching braces in a string

Converting minutes into a readable string

I’d like to start posting some shorter entries. Hopefully that will be more conducive to making posts more often. I’m going to start tagging these as Short Code entries.

For this first one I came across a challenge on reddit about converting a quantity of minutes into a readable string, paraphrasing here:

Write a function that takes in a number of minutes as an integer and returns a string of the format “# years, # months, # days, # hours, #minutes”.

Continue reading Converting minutes into a readable string