Aggregate Advertised Prefixes Into The Minimal Exact Summary

Last updated: November 29, 2026

Quick Overview

Given a list of IPv4 prefixes that may overlap, nest, or be adjacent, return the smallest list of CIDR blocks that covers exactly the same address space, never including addresses that were not in the input.

Cisco
Coding & Algorithms
Software Engineer
Cisco
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given a list of IPv4 prefixes that may overlap, nest, or be adjacent, return the smallest list of CIDR blocks that covers exactly the same address space, never including addresses that were not in the input.

Route summarization keeps OSPF areas and BGP tables small, and Cisco tooling such as Catalyst Center and SD-WAN policy compilers must compute summaries without black-holing unadvertised space. The interviewer checks the interval reduction, alignment-aware splitting, and that you never over-summarize.

What the Interviewer Expects
  • Normalizes prefixes and converts them to integer intervals
  • Sorts and merges overlapping and adjacent intervals
  • Splits each merged interval into maximal aligned power-of-two blocks
  • Proves the result is minimal and exact
  • Handles 0.0.0.0/0 and /32 cleanly
Key Topics to Cover
route summarization
interval merging
CIDR
bit alignment
greedy algorithms
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 allow a controlled amount of over-summarization, say at most 5 percent extra space?
  • How would you maintain the summary incrementally as prefixes are withdrawn?
  • Why can a summary route cause a routing loop or black hole if a component goes down, and what does a discard route to Null0 do?
  • How does this extend to IPv6?
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

Input: CIDR strings, possibly with host bits set. Output: sorted, non-overlapping CIDRs whose union equals the union of the inputs, with the fewest blocks. Exactness is the key constraint: 10.0.1.0/24...

High-Level Design
  1. Convert each prefix to an inclusive integer range [base, base + 2^(32-L) - 1], masking off host bits.
  2. Sort by start and merge ranges that overlap or touch (lo <= prev_hi + 1). Nested prefixe...

Submit Your Answer
Markdown supported

Related Questions