<div dir="ltr"><i>TASK #1<br>Merge Intervals<br>Write a script to merge the given intervals where ever possible.<br><br>[2,7], [3,9], [10,12], [15,19], [18,22]<br><br>The script should merge [2, 7] and [3, 9] together to return [2, 9].<br><br>Similarly it should also merge [15, 19] and [18, 22] together to return [15, 22].<br><br>The final result should be something like below:<br><br>[2, 9], [10, 12], [15, 22]</i><br clear="all"><div><br></div><div>I think this is somewhat ambiguous.</div><div>[2,7] and [3,9] become [2,9] because there's overlap. Nothing overlaps [10,12], so it doesn't get merged.</div><div><br></div><div>But are we taking as given that these are sorted by initial value? If [2,7] was last instead of first, would it still merge with [3,9]? Or are we to take each pair independently, regardless of order? </div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Dave Jacoby<br>
<a href="mailto:jacoby.david@gmail.com" target="_blank">jacoby.david@gmail.com</a><br>
<br>I deal with my software the way I treat my eldritch abomination: <br> It's not human, it's not even alive in the natural sense. </div><div dir="ltr"> It's nightmare-born and nightmare-shaped, and nightmares don't die easy.<br>  -- @yenzie</div></div></div></div></div>