# LeetCode 921. Minimum Add to Make Parentheses Valid https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/description/ ## 題目大意 如題 ## 思考 這題就考很簡單的 balancing count ```cpp! class Solution { public: int minAddToMakeValid(string s) { int l = 0, r = 0; for (const char &c : s) { if (c == '(') ++l; else { if (l > 0) --l; else ++r; } } return l + r; } }; ```
×
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