Sorry for the ambiguity.
I agree what you commented. What I mean is that throwing an exception to set a flag is not quite acceptable. That solution is interesting, but really don't get the point.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.