Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Why does the condition on the first while loop of the solution use a non-inclusi...

hj3yoo

Feb 27, 2022

Why does the condition on the first while loop of the solution use a non-inclusive unequal operator, whereas the second loop uses an inclusive one? Shouldn't you merge two intervals if the end of the first interval is equal to the start of the next interval?

0

0

Comments
Comments
Design Gurus
Design Gurus4 years ago

This first 'while' is checking if there is no overlap so that we can skip merging, that's why non-inclusive check is used.

On this page