-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
https://school.programmers.co.kr/learn/courses/30/lessons/181188
import Foundation
func solution(_ targets:[[Int]]) -> Int {
var targets = targets.sorted(by: { $0[0] < $1[0] })
let f = targets.removeFirst()
var queue: [(Int, Int)] = [(f[0], f[1])]
var ans = 1
for t in targets {
if let q = queue.last {
if q.1 > t[0] {
if q.1 > t[1] {
queue[queue.count - 1].1 = t[1]
}
} else {
queue.append((t[0], t[1]))
ans += 1
}
}
}
return ans
}