20. Valid Parentheses
1.問題
2.想法
提問
function header, parameter
test input
說明想法
左括號時: 放到stack中
右括號時:
若stack是空的或是左右無法match, 回傳false
pop stack
最後回傳判斷stack是否為空
測試計算複雜度: O(n) , n是長的字串的長度
3.程式碼
Last updated
提問
function header, parameter
test input
說明想法
左括號時: 放到stack中
右括號時:
若stack是空的或是左右無法match, 回傳false
pop stack
最後回傳判斷stack是否為空
測試計算複雜度: O(n) , n是長的字串的長度
Last updated