import Foundation
func solution(_ numbers:[Int]) -> [Int] {
var result: [Int] = Array(repeating: -1, count: numbers.count)
var stack: [(Int, Int)] = []
for (i, n) in numbers.enumerated() {
if !stack.isEmpty {
while !stack.isEmpty && stack.last!.1 < n {
result[stack.removeLast().0] = n
}
}
stack.append((i, n))
}
return result
}