Loading...
You are given a string s made of the characters '(', ')', and '*'.
Each '*' may independently be replaced by a '(', by a ')', or by nothing at all. Return true if some choice of replacements turns s into a balanced bracket string, and false otherwise.
A bracket string is balanced when every '(' has a matching ')' after it and every ')' has a matching '(' before it.
Input: s = "()"
Output: true
Input: s = "(*)"
Output: true
Explanation: Treat the '*' as nothing, leaving "()".
Input: s = "(*))"
Output: true
Explanation: Treat the '*' as a '(' , giving "(())".
s.length ≤100s[i] is '(', ')' or '*'.Click "Run" to test with sample cases or "Submit" to run all tests.