Okta·Software Engineer·Technical Phone Screen
- Given an array of strings, write a function that returns true if every string is a valid IPv4 address, and false otherwise. A valid IPv4 address has exactly four dot-separated octets, each containing only digits, no leading zeros, and a value between 0 and 255.
- Follow-up: extend your solution to also handle IPv6 addresses, and instead of returning a boolean, classify each input string as 'IPv4', 'IPv6', or 'Neither'.
“I started with the split-on-dot approach and immediately ran into the leading zeros edge case, which I nearly missed.”