Drill

ProblemsGo › logistics

How many parcels missed the van

easylogisticsArraysGo

Items boarded the van if their ready time is before backstopMinutes. Count how many missed it, so the leftover list can be quoted again.

lateParcels(readyTimes: list<int>, backstopMinutes: int) → int

Go needs a compiler and Drill does not host one yet, so this page is the reference rather than an exercise: the problem, worked examples, and the solution in full. To type it out, the same problem runs in Python.

Solve it in Python →

Where you start

func lateParcels(readyTimes []int, backstopMinutes int) int {
	
}

Worked examples

CallResult
lateParcels([]int{100, 200, 300}, 250)1
lateParcels([]int{250, 250}, 250)0
lateParcels([]int{300}, 100)1
lateParcels([]int{}, 500)0

Hint

Count the ones that fail the comparison.

Reference solution in Go
func lateParcels(readyTimes []int, backstopMinutes int) int {
	n := 0
	for _, t := range readyTimes {
		if t > backstopMinutes {
			n++
		}
	}
	return n
}

The same problem in another language

More logistics problems in Go