``` 開カッコと閉カッコからなる文字列が与えられる。 開カッコと閉カッコがきちんと対応している場合にはTrueを、それ以外の場合にはFalseを返してください。 # 入力と出力の例 () => True )( => False # 閉カッコが先に来てしまっている ( => False ()() => True (()) => True (())) => False ())(() => False ``` ```typescript= function checkBraces(input) { if (input.includes("()")) return checkBraces(input.replace("()", "")); return input === ""; } ``` ```typescript= ["()", "()()", "(())", "(())()", "(()(())())"].every(v => checkBraces(v)) // true [")(", "(", "(()))", "())(()"].every(v => !checkBraces(v)) // true ``` - True - False - (()(())()) - (())() - ())( - (())()
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up