Tuesday, 1 October 2013

minimum value not in an array of intervals

minimum value not in an array of intervals

You have a list of N integer intervals, and the possible integer values
range from 1 to N^3.
For example, you can have N=5 and intervals
([1,5],[2,9],[18,25],[10,15],[20,22]). I'm trying to figure out an
algorithm to return the smallest integer not in those intervals, i.e. 16,
with a runtime of O(N).
Please help!

No comments:

Post a Comment