Re: [閒聊] 每日leetcode已回收
好像就先用stack照做
不知道有沒有其他騷作法
有空來看看
def reverseParentheses(self, s: str) -> str:
stk = []
for c in s:
if c == ")":
tmp = []
while stk[-1] != "(":
tmp.append(stk.pop())
stk.pop()
stk += tmp
else:
stk.append(c)
return "".join(stk)
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1720658213.A.6CD.html
推
07/11 08:38,
1年前
, 1F
07/11 08:38, 1F
→
07/11 08:39,
1年前
, 2F
07/11 08:39, 2F
→
07/11 08:40,
1年前
, 3F
07/11 08:40, 3F
→
07/11 08:43,
1年前
, 4F
07/11 08:43, 4F
討論串 (同標題文章)
完整討論串 (本文為第 471 之 1554 篇):