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

歡迎光臨散文網(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)論 (共 條)

分享到微博請遵守國家法律
黔西县| 永济市| 华坪县| 禹城市| 镇江市| 两当县| 大足县| 融水| 河津市| 大同市| 新巴尔虎左旗| 昭苏县| 客服| 环江| 郸城县| 茌平县| 科技| 苏尼特右旗| 鸡东县| 枞阳县| 绵竹市| 泰宁县| 尤溪县| 乌拉特中旗| 巴彦淖尔市| 寻乌县| 共和县| 仁寿县| 大田县| 兴宁市| 奉化市| 巍山| 汕头市| 舒城县| 社会| 抚顺县| 镇坪县| 饶平县| 儋州市| 栖霞市| 南投县|