Drill

ProblemsGo › scheduling

Do these two shifts overlap

easyschedulingIntervalsGo

Time-and-a-half rules ban one person covering two shifts at once. Minutes are counted from midnight; decide whether two shift windows share any time at all.

shiftsOverlap(firstStart: int, firstEnd: int, secondStart: int, secondEnd: int) → bool

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 shiftsOverlap(firstStart int, firstEnd int, secondStart int, secondEnd int) bool {
	
}

Worked examples

CallResult
shiftsOverlap(480, 900, 840, 1020)true
shiftsOverlap(480, 900, 900, 1020)false
shiftsOverlap(480, 840, 900, 1020)false
shiftsOverlap(480, 900, 500, 600)true

Hint

Two windows overlap exactly when each starts before the other ends.

Reference solution in Go
func shiftsOverlap(firstStart int, firstEnd int, secondStart int, secondEnd int) bool {
	return firstStart < secondEnd && secondStart < firstEnd
}

The same problem in another language

More scheduling problems in Go