Merge Member Eligibility Spans Including Back to Back Coverage

Last updated: November 29, 2026

Quick Overview

Given eligibility records as (member_id, start_date, end_date) with inclusive dates, return for each member the minimal list of continuous coverage periods, merging spans that overlap or that start the day after another ends.

Cognizant
Coding & Algorithms
Software Engineer
Cognizant
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given eligibility records as (member_id, start_date, end_date) with inclusive dates, return for each member the minimal list of continuous coverage periods, merging spans that overlap or that start the day after another ends.

Payer platforms like TriZetto Facets store eligibility as many small spans created by plan changes, and claims adjudication needs continuous coverage periods to decide whether a service date is covered. The interviewer is checking interval merging plus the detail that inclusive dates make adjacent spans continuous.

What the Interviewer Expects
  • Groups by member before merging
  • Sorts spans by start date within each member
  • Treats next start equal to previous end plus one day as continuous
  • Extends the end with max, handling fully contained spans
  • Validates start not after end
  • States O(n log n) complexity
Key Topics to Cover
interval merging
sorting
date handling
healthcare eligibility
grouping
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you answer many queries of the form: was member M covered on date D?
  • Spans also carry a plan ID and you must only merge within the same plan. What changes?
  • How would you find coverage gaps longer than 63 days for each member?
  • How would you do this in SQL instead of Python?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Inputs are rows (member_id, start, end) with ISO dates, both ends inclusive. Output maps each member to sorted, non-overlapping periods. Two spans join when they overlap or are adjacent: Jan 1 to Ma...

High-Level Design

Bucket spans by member with a defaultdict(list). For each bucket sort by start, then sweep: keep the last merged period; if the next start is on or before last_end + 1 day, extend `last_end = max(...


Submit Your Answer
Markdown supported

Related Questions