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 b6acb32 commit 950bb43Copy full SHA for 950bb43
valid-palindrome/se6816.java
@@ -0,0 +1,37 @@
1
+/**
2
+ 투포인터 방식을 통해 맨 앞과 맨 끝 포인터에서 맨 끝 포인터가 맨 앞 포인터를 앞지를 때까지 비교하는 방식
3
+ 문자열 s의 길이 -> N
4
+ 시간 복잡도 : O(N)
5
+ 공간 복잡도 : O(1)
6
+ */
7
+class Solution {
8
+ public boolean isPalindrome(String s) {
9
+ s=s.toUpperCase();
10
+ int start=0;
11
+ int end=s.length()-1;
12
+ while(start < end){
13
+ char ch=s.charAt(start);
14
+ char ch2=s.charAt(end);
15
+
16
+ // 문자 체크
17
+ if(!((ch>=65 && ch<=90) || (ch>=48 && ch<=57))){
18
+ start++;
19
+ continue;
20
+ }
21
+ if(!((ch2>=65 && ch2<=90) || (ch2>=48 && ch2<=57))){
22
+ end--;
23
24
25
26
+ if(ch==ch2){
27
28
29
30
31
32
+ return false;
33
34
35
+ return true;
36
37
+}
0 commit comments