So I need to create a program that can determine if a set of parentheses is balanced or not as well as determine which parenthesis is the first "offending parenthesis" meaning the first parenthesis to not be part of a balanced pair.
I could only come up with a program that determined if the set of parentheses were balanced or not, but couldn't figure out a common detection method for the first parenthesis that doesn't belong to a pair.
Ex: In "(())(()(" the fifth parenthesis is the first offending parenthesis.
I've tried many ways to find the first offending parenthesis, but they didn't work for every single case, so please let me know if you have a better algorithm in mind. I'm supposed to implement this with the stack concept in mind.