mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-10 00:09:06 +01:00
15 lines
320 B
Go
15 lines
320 B
Go
package main
|
|
|
|
func averageWaitingTime(customers [][]int) float64 {
|
|
waitingTime := 0
|
|
|
|
idleAt := 0
|
|
for _, customer := range customers {
|
|
arrives, length := customer[0], customer[1]
|
|
|
|
idleAt = max(idleAt, arrives) + length
|
|
waitingTime += idleAt - arrives
|
|
}
|
|
|
|
return float64(waitingTime) / float64(len(customers))
|
|
}
|