본문 바로가기 메뉴 바로가기

Peppo

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

Peppo

검색하기 폼
  • 분류 전체보기 (221)
    • Story (13)
    • iOS (143)
      • Error (11)
    • 알고리즘 (43)
    • ETC (7)
    • React-Native (0)
    • CS (Computer science) (3)
  • 방명록

isNumber (1)
[Swift 알고리즘] - Valid Palindrome (LeetCode)

https://leetcode.com/problems/valid-palindrome/description/ 주어진 문장(s)을 소문자로 바꾼후, 영문/숫자가 아닌걸 제거하고, 주어진 문장과 거꾸로 읽어도 똑같다면 true를 리턴, 다르다면 false를 리턴 내 풀이 class Solution { func isPalindrome(_ s: String) -> Bool { let convertedStr = s .lowercased() .filter { $0.isNumber || $0.isLetter } let reversedStr = String(convertedStr.reversed()) return convertedStr == reversedStr ? true : false } } 소문자로 바꿔주는 메서드..

알고리즘 2023. 8. 22. 07:49
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
  • Peppo's Github
TAG
  • swift 고차함수
  • Swift inout
  • CS 네트워크
  • Combine: Asynchronous Programming with Swift
  • swift programmers
  • Swift 프로퍼티
  • Swift 알고리즘
  • Swift Error Handling
  • RIBs tutorial
  • swift protocol
  • swift (programmers)
  • removeLast()
  • Swift
  • 2023년 회고
  • RTCCameraVideoCapturer
  • swift reduce
  • iOS error
  • Swift Leetcode
  • Swift joined
  • Swift RIBs
  • Swift 프로그래머스
  • ios
  • Swift ModernRIBs
  • Swift 내림차순
  • Swift final
  • Class
  • swift property
  • Swift joined()
  • Swift init
  • 원티드 프리온보딩
more
«   2025/05   »
일 월 화 수 목 금 토
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바