Given a string containing nested parentheses, write an algorithm to validate if the structure is balanced.