This commit is contained in:
2025-09-15 21:12:04 +08:00
commit 3f58f483ff
144 changed files with 5298 additions and 0 deletions

52
else/kuohao.h Normal file
View File

@@ -0,0 +1,52 @@
//
// Created by 李洋 on 2023/10/4.
//
#ifndef LEECODE_C_KUOHAO_H
#define LEECODE_C_KUOHAO_H
#include <string>
#include <stack>
bool isKuoHao(std::string target) {
std::stack<char> tk;
for (int i = 0; i < target.length(); ++i) {
if (tk.empty()) {
tk.push(target[i]);
continue;
}
char temp;
switch (target[i]) {
case '{':
temp = '}';
break;
case '}':
temp = '{';
break;
case '[':
temp = ']';
break;
case ']':
temp = '[';
break;
case '(':
temp = ')';
break;
case ')':
temp = '(';
break;
default:
temp = 'x';
}
if (temp == tk.top()) {
tk.pop();
} else {
tk.push(target[i]);
}
}
return tk.empty();
}
// cout << isKuoHao("{}(({}))") << endl;
#endif //LEECODE_C_KUOHAO_H