1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-14 01:49:41 +01:00
LeetCode/go/average-waiting-time.go
Matej Focko 8198249ac5
go: add «1701. Average Waiting Time»
Signed-off-by: Matej Focko <me@mfocko.xyz>
2024-07-09 09:52:12 +02:00

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))
}