-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
๐ฌย ๋ฌธ์
https://school.programmers.co.kr/learn/courses/30/lessons/42747#fn1
๐ฌย ํ์ด
func solution(citations:[Int]) -> Int {
var HIndex = 0
for i in 0..<citations.max()! {
let up = citations.filter({ $0 >= i }).count
let down = citations.filter({ $0 < i }).count
if up >= i && down <= i {
HIndex = max(HIndex, i)
}
}
return HIndex
}
๐ฌย ๋ ๋์ ๋ฐฉ๋ฒ?
func solution(citations:[Int]) -> Int {
let citations = citations.sorted(by: >)
var ans = 0
for i in 0..<citations.count {
if i + 1 <= citations[i] {
ans = i + 1
} else {
break
}
}
return ans
}