Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- WWDC
- modern concurrency deep dive
- modern concurrency
- 티스토리챌린지
- APNS
- 야곰 # 야곰아카데미커리어스타터캠프 #iOS개발자 # 부트캠프
- SWIFT
- 오블완
- ios
Archives
- Today
- Total
Geon
FrogRiverOne 본문
func solution() -> Int{
let X = 5
let A = \[1,3,1,4,2,3,5,4\]
var list = Array.init(repeating: 0, count: X + 1)
var result = 0
for (index, item) in A.enumerated() {
list\[0\] = 1
list\[item\] += 1
if list.allSatisfy({ $0 >= 1}) {
result = index
break
} else {
result = -1
}
}
return result
}
print(solution())
allSatisfy로 만족하는 결과값을 찾을수 있다.
'코딩테스트' 카테고리의 다른 글
Two Pointer (2) | 2024.01.06 |
---|---|
제한 조건 보는 법 (0) | 2024.01.04 |
OddOccurrencesInArray (0) | 2022.05.13 |
요세푸스 문제[BOJ] (0) | 2022.03.26 |
큐[BOJ] (0) | 2022.03.25 |