ShannonHung / ShannonHung.github.io

2 stars 0 forks source link

LeetCode #20 Valid Parentheses - 刷題之旅 | Shannon's Blog 🐟 技術 | 生活 | 旅行 #106

Open ShannonHung opened 3 months ago

ShannonHung commented 3 months ago

https://shannonhung.github.io/posts/leetcode-120-valid-parentheses/

1 題目描述 這是一個括號匹配的問題,給一個只包含(, ), {, }, [, ]的字符串,目的是要檢查一個字串是否是有效的括號組合。 2 解法 我的想法很簡單: 先建立一個 dictionary,把所有的括號對應關係記錄下來。 key 是 (, {, [,value 是說明 key 的方向(open or close)與屬性(大, 中, 小括號)。 開始遍歷字串

leozzmc commented 3 months ago

我是你的粉絲