⌘K
Flycodx

Newspaper Zone Multi-Route Coverage

Newspaper Zone Multi-Route Coverage

MediumArrays100% accepted

In Delhi, there are N newspaper delivery routes, each covering a zone from start to end position. Priya identifies which zones are covered by exactly K different routes to plan high-priority delivery areas. Rule: positions are integers; a route [s,e] covers s..e inclusive. Return (ascending) every position covered by EXACTLY k routes, [] if none. Your solve(...) function receives the inputs as ready-made arguments — no input reading or parsing needed; just return the answer.

Approach

Given N intervals [start, end] and integer K, find all positions covered by exactly K intervals.

Input

routes=[[0,3],[2,5],[1,4]] k=2

Output

[1,4]
solution.py
Loading editor...
Test 1
Test 2
Test 3

Press Run to test your custom input, or Submit to judge against all test cases.

Sign in to continue

Create a free account to run code, submit solutions and track progress.

  • Free forever — no credit card
  • 10+ languages with live execution
  • Points, streaks & leaderboards
Auto Save OnLn 1, Col 1Spaces: 4UTF-8LFPython 3