Implement the meetingOverlapCheck method that checks whether two time intervals overlap.

The input contains two meeting intervals: start1, end1, start2, and end2. Your task is to check whether the two meetings overlap.

Two meetings overlap if they share any common time. If one meeting ends exactly when the other starts, they do not overlap.

Example 1

Input
start1 (int) = 10
end1 (int) = 20
start2 (int) = 15
end2 (int) = 25
Returns (boolean) true

Example 2

Input
start1 (int) = 10
end1 (int) = 20
start2 (int) = 20
end2 (int) = 30
Returns (boolean) false

Example 3

Input
start1 (int) = 1
end1 (int) = 5
start2 (int) = 2
end2 (int) = 3
Returns (boolean) true

Use the standard interval overlap condition.

For two intervals to overlap, the first meeting must start before the second meeting ends, and the second meeting must start before the first meeting ends.

If either meeting ends before or exactly when the other begins, there is no overlap.

Pseudocode:

function meetingOverlapCheck(start1, end1, start2, end2):
    if start1 < end2 and start2 < end1:
        return true
    return false
Ready to test your solutionRun Code checks your solution against the test cases.Shift + Enter to run

Notifications

Updates are enabled for this browser.

Receive new tutorials, articles and learning resources. You can turn updates off anytime.

Test browser code

Use this code in admin to send a test notification to this browser.