Skip to content

Commit 9540c6c

Browse files
committed
Solution Valid-palindrome
1 parent 51bf3f2 commit 9540c6c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

valid-palindrome/HISEHOONAN.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// Untitled.swift
3+
// Algorithm
4+
//
5+
// Created by 안세훈 on 4/14/25.
6+
//
7+
8+
class Solution {
9+
func isPalindrome(_ s: String) -> Bool {
10+
var validS = s.lowercased().filter{$0.isNumber == true || $0.isLetter == true}
11+
//s를 모두 소문자로 변환 후 숫자 or 문자가 true인 문자만 validS에 배열로 추출.
12+
13+
if validS == String(validS.reversed()){ //validS와 뒤집은 것과 같다면 true 아니면 false
14+
return true
15+
}else{
16+
return false
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)