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

30
else/symmetry.h Normal file
View File

@@ -0,0 +1,30 @@
//
// Created by 李洋 on 2023/10/4.
//
#ifndef LEECODE_C_SYMMETRY_H
#define LEECODE_C_SYMMETRY_H
#include <string>
#include <stack>
bool isSymmetry(std::string target) {
std::stack<char> tk;
for (int i = 0; i < target.length(); ++i) {
if (i < target.length() / 2) {
tk.push(target[i]);
}
if (i == target.length() / 2 && target.length() % 2 == 1) {
i++;
}
if (i >= target.length() / 2) {
if (target[i] != tk.top()) {
return false;
}
tk.pop();
}
}
return true;
}
#endif //LEECODE_C_SYMMETRY_H