Output will appear here...
You are given a string made only of ( and ) characters.
Write a function correct_bracketing(brackets) that returns True if every opening bracket has a matching closing bracket that comes after it, and False otherwise. For example, "(()())" is correct, but ")(()" is not, even though the counts match.
Tip
You don't need a full stack for a single kind of bracket. A counter that goes up for ( and down for ) is enough. What two things must be true about the counter?
The starter code reads one non-empty string and prints true or false.
No comments yet. Start the discussion.