diff --git a/content/leetcode/2023/9.md b/content/leetcode/2023/9.md index 46c43c4b8..16e511650 100644 --- a/content/leetcode/2023/9.md +++ b/content/leetcode/2023/9.md @@ -3,6 +3,34 @@ title: 2023.9 draft: false --- +# 2023.9.13 + +```python +# +# @lc app=leetcode.cn id=921 lang=python3 +# +# [921] 使括号有效的最少添加 +# + + +# @lc code=start +class Solution: + def minAddToMakeValid(self, s: str) -> int: + stack = [] + for i in s: + if i == "(": + stack.append(i) + else: + if stack and stack[-1] == "(": + stack.pop() + else: + stack.append(i) + return len(stack) + + +# @lc code=end +``` + # 2023.9.12 ```python