Valid Parentheses
Given a string s
containing just the characters '('
, ')'
, '{'
, '}'
, '['
and ']'
, determine if the input string is valid.
An input string is valid if:
Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
์๋ฃ๊ตฌ์กฐ : Stack ๊ณผ Map
์๊ณ ๋ฆฌ์ฆ 0.Map๊ณผ Stack ์์ฑํ๋ค. - Map(key,value) = Map( '(' , ')' ) 1. open bracket์ด ๋์ค๋ฉด ์คํ์ ๋ฃ๋๋ค. 2. closed bracket์ด ๋์ค๋ฉด 1๊ณผ ์์ํ๋ ๊ฒ์ธ์ง ํ์ธํ๋ค. 2. ์คํ์ด ๋น์ด์๋ค๋ฉด validํ๋ค. - .empty()๋ก true ๋ฆฌํด
Last updated