Drill

ProblemsJavaScript › scheduling

Do these two shifts overlap

easyschedulingJavaScript

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

Solve it in the editor →

Where you start

function shiftsOverlap(firstStart, firstEnd, secondStart, secondEnd) {
  
}

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 JavaScript
function shiftsOverlap(firstStart, firstEnd, secondStart, secondEnd) {
  return firstStart < secondEnd && secondStart < firstEnd;
}

The same problem in another language

More scheduling problems in JavaScript