dividing N ranges into two subsets [closed]

落爺英雄遲暮 提交于 2019-12-17 20:43:12

问题


There are N ranges [l1,r1],[l2,r2],…,[lN,rN]

. rosy wants to divide the ranges into two non-empty subsets in such a way that each range is in exactly one subset and whenever two ranges have a common point, they are in the same subset.

Since this could be difficult to achieve, rosy can delete any number of ranges (possibly zero) and then divide the remaining ranges into such non-empty subsets. She wants to know whether it is possible to achieve her task after deleting some ranges and if it is possible, she also wants to know the minimum number of ranges she needs to delete to achieve it.

> For example if the input ranges are [1,4],[2,6],[5,7]
>  Out put should be 1 as deleting [2,6] is sufficient.


>if input is [1,4] and [4,6]
>out put should be -1


>if input ranges are [3,7] and [8,9]
>the out put should be 0

My question is what exactly she wants to do .If possible suggest some test cases.

来源:https://stackoverflow.com/questions/59307236/dividing-n-ranges-into-two-subsets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!