×

Loading...

@Ottawa

Topic

This topic has been archived. It cannot be replied.
  • 工作学习 / 学科技术 / 生活所迫,也得上leetcode刷题了。无奈缺乏训练,只能从easy级别的题开始。感觉还是很有收获的。几天的工夫,才做了几道题。没想到 20. Valid Parentheses 这道题,速度居然超过了100%的C++提交代码。小小开森一下。当脑筋急转弯了。LOL +3

    20. Valid Parentheses

    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.

    ​​​​​​​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 '()[]{}'.

    Accepted

    2,167,977

    Submissions

    5,304,870

    • 👍👍👍