Skip to content

Commit

Permalink
Merge pull request #144 from AlgoLeadMe/36-Munbin-Lee
Browse files Browse the repository at this point in the history
36-Munbin-Lee
  • Loading branch information
MunbinLee authored Mar 4, 2024
2 parents df1db55 + 5a22efe commit 84d26c3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions Munbin-Lee/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@
| 33์ฐจ์‹œ | 2024.02.04 | ์ •์ˆ˜๋ก  | <a href="https://www.acmicpc.net/problem/14905">์†Œ์ˆ˜ 4๊ฐœ์˜ ํ•ฉ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/128 |
| 34์ฐจ์‹œ | 2024.02.06 | ๊ตฌํ˜„ | <a href="https://www.acmicpc.net/problem/1756">ํ”ผ์ž ๊ตฝ๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/133 |
| 35์ฐจ์‹œ | 2024.02.18 | ๋ฐฑํŠธ๋ž˜ํ‚น | <a href="https://www.acmicpc.net/problem/24891">๋‹จ์–ด ๋งˆ๋ฐฉ์ง„</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/140 |
| 36์ฐจ์‹œ | 2024.02.21 | ๋ฌธ์ž์—ด | <a href="https://www.acmicpc.net/problem/15927">ํšŒ๋ฌธ์€ ํšŒ๋ฌธ์•„๋‹ˆ์•ผ!!</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/143 |
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <iostream>
#include <unordered_set>

using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

string s;
cin >> s;

if (unordered_set<char>(s.begin(), s.end()).size() == 1) {
cout << "-1";
return 0;
}

auto isPalindrome = [](string &s) {
int lo = 0;
int hi = s.size() - 1; // NOLINT

while (lo < hi) {
if (s[lo] != s[hi]) return false;
lo++;
hi--;
}

return true;
};

if (!isPalindrome(s)) {
cout << s.size();
return 0;
}

cout << s.size() - 1;

return 0;
}

0 comments on commit 84d26c3

Please sign in to comment.