새소식

인기 검색어

프로그래머스/Lv.1

[Swift] 크기가 작은 부분 문자열

  • -
import Foundation

func solution(_ t:String, _ p:String) -> Int {
    var index = 0
    var result = [String]()
    
    var t = Array(t).map { String($0)}
    
    
    
    while index + p.count <= t.count {
        result.append(t[index..<index+p.count].joined())
        index += 1
    }
    
    return result.filter {$0 <= p}.count
}

 

'프로그래머스 > Lv.1' 카테고리의 다른 글

[Swift] 키패드 누르기  (0) 2023.02.16
[Swift] 크레인 인형 뽑기  (0) 2023.02.16
[Swift] 콜라츠 추측  (0) 2023.02.16
[Swift] 콜라 문제  (0) 2023.02.16
[Swift] 최소 직사각형  (0) 2023.02.16
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.