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 783ff8a commit ea58a3bCopy full SHA for ea58a3b
โvalid-palindrome/YoungSeok-Choi.java
@@ -0,0 +1,31 @@
1
+
2
+// NOTE: ํฐ๋ฆฐ๋๋กฌ์ ์ํ๋ฒณ ์๋ฌธ์์ "์ซ์" ๊น์ง ํฌํจํ๋๋ฏ ํ๋ค.
3
+// O(n) ์๊ณ ๋ฆฌ์ฆ.
4
+import java.util.stream.Collectors;
5
6
+class Solution {
7
+ public boolean isPalindrome(String s) {
8
9
+ String filtered = s.chars()
10
+ .filter(Character::isLetterOrDigit)
11
+ .mapToObj(c -> String.valueOf((char) c))
12
+ .map(String::toLowerCase)
13
+ .collect(Collectors.joining());
14
15
+ char[] cArr = filtered.toCharArray();
16
17
+ int startIdx = 0;
18
+ int endIdx = cArr.length - 1;
19
20
+ while(startIdx < endIdx) {
21
+ if(cArr[startIdx] != cArr[endIdx]) {
22
+ return false;
23
+ }
24
25
+ startIdx++;
26
+ endIdx--;
27
28
29
+ return true;
30
31
+}
0 commit comments