最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

Leetcode 20. Valid Parentheses

2023-03-01 10:02 作者:您是打尖兒還是住店呢  | 我要投稿

Given a string?s?containing just the characters?'(',?')',?'{',?'}',?'['?and?']', determine if the input string is valid.

An input string is valid if:

  1. Open brackets must be closed by the same type of brackets.

  2. Open brackets must be closed in the correct order.

  3. Every close bracket has a corresponding open bracket of the same type.

?

Example 1:

Input: s = "()"Output: true

Example 2:

Input: s = "()[]{}"Output: true

Example 3:

Input: s = "(]"Output: false

?

Constraints:

  • 1 <= s.length <= 104

  • s?consists of parentheses only?'()[]{}'.

easy 題目,其實(shí)用stack來做,速度會(huì)提高很多的。





Runtime:?186 ms, faster than?5.93%?of?Java?online submissions for?Valid Parentheses.

Memory Usage:?42.9 MB, less than?5.76%?of?Java?online submissions for?Valid Parentheses.


Leetcode 20. Valid Parentheses的評(píng)論 (共 條)

分享到微博請遵守國家法律
松溪县| 苏尼特左旗| 安阳县| 永城市| 宁都县| 襄汾县| 南宫市| 梅州市| 华亭县| 板桥市| 宾阳县| 澄迈县| 武清区| 宁波市| 巴中市| 商洛市| 专栏| 东山县| 南投市| 兰考县| 崇义县| 宝鸡市| 昌平区| 宽城| 鄯善县| 兴业县| 宣武区| 峨眉山市| 吉林省| 台北县| 博野县| 浦东新区| 昌都县| 五河县| 长治市| 皋兰县| 长垣县| 印江| 柳江县| 贞丰县| 怀柔区|