Algorithm · IBM · Medium
In an access-control system, every employee id comes with a fixed access length T[id]. The system reads m setup records of the form (id, t), sorted so that times never decrease. The first record for an employee grants them access over the interval $$[t, t + T[id]]$$. Any later record for that same employee can only extend their access if there has been no break in it: When $$t \le expiry[id]$$, the access is renewed and $$expiry[id] = \max(expiry[id], t + T[id])$$. When $$t…