We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b49e57c commit 3ac0bacCopy full SHA for 3ac0bac
125/4.cpp
@@ -0,0 +1,29 @@
1
+// 3重ループを1重ループとしたコード
2
+class Solution {
3
+public:
4
+ bool isPalindrome(string s) {
5
+ if (s.empty()) abort();
6
+ int left = 0, right = s.size()-1;
7
+
8
+ while (left < right) {
9
+ if (!isalnum(s[left])) {
10
+ left++;
11
+ continue;
12
+ }
13
14
+ if (!isalnum(s[right])) {
15
+ right--;
16
17
18
19
+ if (tolower(s[left]) != tolower(s[right])) {
20
+ return false;
21
22
23
24
25
26
27
+ return true;
28
29
+};
0 commit comments