Problem · String
IPv4 Forward 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 increasing numeric order until 255.255.255.255 is reached.
The starting address and 255.255.255.255 are both included. Incrementing an address carries across octets, so the address after 10.0.0.255 is 10.0.1.0.
Interview context
The phone-screen version asked candidates to implement a Python IPV4Iterator with __init__, __iter__, and __next__. It began at the supplied address and yielded every address through the IPv4 upper bound. This function returns the exact finite sequence that iterator would yield.
Function
iterateIPv4Forward(startIp: String) → String[]Examples
Example 1
startIp = "255.255.255.253"return = ["255.255.255.253", "255.255.255.254", "255.255.255.255"]The final octet advances twice before the maximum IPv4 address is reached.
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