Write a function to check for balanced parentheses in a string, or explain how you would handle an array-based data structure problem.