Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
leetcode: finished #921
Browse files Browse the repository at this point in the history
  • Loading branch information
xqm32 committed Sep 13, 2023
1 parent 097f0ef commit 17b63f1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions content/leetcode/2023/9.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 17b63f1

Please sign in to comment.