educative.io

Educative

Why is [5,5] not a part of the answer for test case 1?

I am referring to this test case where inputs are:
list1 = {1, 3}, {5, 6}, {7, 9}
list2 = {2, 5}, {5, 7}

According to the logic of the solution provided, it should take [5, 5] as an intersection when it checks for an intersection between [2, 5] and [5, 6].

Could anyone explain why [5, 5] is not included in the answer? I believe it should because it is a valid intersection.


Type your question above this line.

Course: https://www.educative.io/collection/5668639101419520/5671464854355968
Lesson: https://www.educative.io/collection/page/5668639101419520/5671464854355968/6518042546667520

Hey @Kedar_Sambhus
[5,5] represents a single value that is 5. This interval is considered to be a degenerate interval. A real interval is neither empty nor degenerate. Therefore, [5,5] cannot be considered a real interval and so it’s not a valid intersection.

Why is [7, 7] part of the solution then?

Why is [5, 5] not part of a solution but [7, 7] is?

[5, 5] would be a valid answer, but we don’t need to mention it separately, as it is already a part of [5, 6] which is a part of the answer.