Valid Parentheses

来源:互联网 发布:mac os 10.6.8下载dmg 编辑:程序博客网 时间:2024/04/29 16:06
class Solution {public:    bool isValid(string s) {        stack<char> st;        for(int m = 0;m < s.size();++m){            if(!st.empty() && (s[m] + st.top() == 81 || s[m] + st.top() == 184 || s[m] + st.top() == 248))                st.pop();            else                st.push(s[m]);        }        if(st.empty())            return true;        else return false;    }};

0 0
原创粉丝点击