leetcode-301-Remove Invalid Parentheses

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zem_nezer/article/details/86665453

Error:

  1. s.erase() will erase the char in s then return!!! If you want to get the s.erase and s, it should use another string to store s then erase the char
  2. Do not know how to do: when an parenthese is valid will have:
    - If i not in the end, left >= right
    - If i meet the end, left == right

    In other word, any string do not has this case is invalid, so that we can use a variable to check it.
    Then, we first delete the first parenthese when meet duplicate and delete “)” first to ensure the prefix is valid first

猜你喜欢

转载自blog.csdn.net/zem_nezer/article/details/86665453