Problem · String
IPv4 Reverse Iterator
Learn this problemProblem statement
You are given an IPv4 address as a dotted-decimal string. Starting at that address, visit every IPv4 address in decreasing numeric order until 0.0.0.0 is reached.
The starting address and 0.0.0.0 are both included. Decrementing an address borrows across octets, so the address before 10.0.1.0 is 10.0.0.255.
Interview context
The second part of the phone-screen prompt reversed the iterator: begin at the supplied IPv4 address, decrement one address at a time, and continue through 0.0.0.0. This function returns the exact finite sequence that iterator would yield.
Function
iterateIPv4Reverse(startIp: String) → String[]Examples
Example 1
startIp = "0.0.0.2"return = ["0.0.0.2", "0.0.0.1", "0.0.0.0"]The address decreases by one until the lower IPv4 bound is included.
More OpenAI problems
- Memory AllocatorPHONE SCREEN · Seen Jul 2026
- Message Event AggregationONSITE INTERVIEW · Seen Jul 2026
- Plant Infection Simulation, Part 4: Death CountdownPHONE SCREEN · Seen Jun 2026
- Streaming Entropy, Part 1: Batch EntropyONSITE INTERVIEW · Seen Jun 2026
- Streaming Entropy, Part 2: Numerically Stable EntropyONSITE INTERVIEW · Seen Jun 2026
- Streaming Entropy, Part 3: Block-wise EntropyONSITE INTERVIEW · Seen Jun 2026
- Streaming Entropy, Part 4: Stable Streaming EntropyONSITE INTERVIEW · Seen Jun 2026
- Resumable List IteratorPHONE SCREEN · Seen Jun 2026