文章
38
粉丝
56
获赞
64
访问
3.9k
#include <bits/stdc++.h>
using namespace std;
int get_rank(char c) {
if (c == '{') return 4;
else if (c == '[') return 3;
else if (c == '(') return 2;
else if (c == '<') return 1;
return 0;
}
char right_to_left(char c) {
switch(c) {
case '}': return '{';
case ']': return '[';
case ')': return '(';
case '>': return '<';
default: return '\0';
}
}
bool is_valid(const string& s) {
char stack[256];
int top = -1;
for (char c : s) {
if (c != '{' && c != '[' && c != '(' && c != '<' ...
登录后发布评论
暂无评论,来抢沙发