iOS 개발 공부
[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 |