The memory constraint is what makes this interesting.
Represent the IP address as a 32-bit unsigned integer internally, and implement next() by incrementing this integer and converting back to dotted-decimal string. Handle wrap-around by using modulo 2^32 arithmetic, and track the number of addresses returned or compare against the end IP to know when to stop.
Pro tip: Mention that using a 32-bit integer avoids string parsing overhead and makes wrap-around trivial; also note that the class should be memory-efficient by not storing addresses, and discuss thread-safety if the iterator might be shared.
Ask about input format (string vs integer), whether the range is inclusive, and how wrap-around should behave (e.g., from 255.255.255.255 to 0.0.0.0). Confirm that next() should return a string and that memory usage must be constant.
Decide to store the current IP as a 32-bit unsigned integer (e.g., uint32_t) to simplify arithmetic and avoid repeated string conversions. Explain how to convert between dotted-decimal string and integer.
Implement next() by incrementing the integer with modulo 2^32 to handle wrap-around. Maintain a counter or compare against the end IP to determine when to stop, returning null or throwing an exception when exhausted.
In the constructor, parse the start IP and either the count or end IP. Compute the total number of addresses if needed, and set up the stopping condition. Ensure that if count is zero or start > end (without wrap), the iterator is immediately exhausted.
Mention that integer arithmetic is O(1) per next() call and uses O(1) memory. Discuss potential overflow issues, thread-safety, and whether to precompute the end integer for faster comparison.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.