# 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; } }; ```