I am reading the Algorithm Design Manual Second Edition and this is from an exercise question. Quoting the question
A common problem for comp
Why have a return value and an out parameter that give the same information?
You could return an int: -1 = balanced, otherwise the index of the error.