← Okta Interview Insights

Okta·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Okta SWE interview that leaned heavily on string parsing and validation logic. The main problem was IPv4 validation with a follow-up pushing into IPv6 classification, which I did not see coming.

Questions Asked (2)

Q1

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.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I started with the split-on-dot approach and immediately ran into the leading zeros edge case, which I nearly missed.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the exact validation rules and edge cases, then propose a clean solution that splits each string by dots and validates each octet. Discuss trade-offs between regex and manual parsing, and consider performance for large arrays.

Pro tip: Mention that you would avoid regex for performance-critical code and instead use a manual parser, but note that regex is acceptable for readability if performance is not a concern. Also, highlight the importance of handling edge cases like empty strings and leading zeros.

1. Clarify requirements and edge cases

Confirm the definition of a valid IPv4 address, including rules for leading zeros, empty octets, and non-digit characters. Ask about input constraints (e.g., array size, string length) to guide optimization.

2. Choose an approach

Decide between using a regular expression or manual parsing. Discuss the trade-offs: regex is concise but may be slower and harder to debug; manual parsing is more verbose but faster and more controllable.

3. Implement the validation logic

For each string, split by '.', check that there are exactly four parts, and validate each part: non-empty, only digits, no leading zeros (unless the part is '0'), and numeric value between 0 and 255.

4. Test with edge cases

Walk through examples: valid addresses like '192.168.0.1', invalid ones like '256.1.1.1', '1.1.1', '1.1.1.1.1', '01.1.1.1', and empty strings. Ensure the function returns false for any invalid string.

5. Analyze complexity and optimize

State that the time complexity is O(n*m) where n is the number of strings and m is the average string length. Mention that early termination (returning false as soon as an invalid string is found) can improve average-case performance.

Key Points to Mention

  • Exactly four octets separated by dots.
  • Each octet must be a numeric string with no leading zeros (except '0' itself).
  • Each octet's value must be between 0 and 255 inclusive.
  • Trade-offs between regex and manual parsing: regex is concise but may be slower and less readable; manual parsing is more efficient and easier to debug.
  • Edge cases: empty strings, extra dots, non-digit characters, leading zeros, and values out of range.
  • Time complexity: O(n*m) for n strings of average length m, with potential for early termination.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

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'.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Did not prepare for this at all.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the exact formats for IPv4 and IPv6, including edge cases like leading zeros and compressed notation. Then, design a modular solution with separate validation functions for each IP version, and finally combine them to classify the input. Discuss trade-offs between regex and manual parsing, and consider using built-in libraries for robustness.

Pro tip: Mention that you would use a well-tested library like Python's ipaddress module in production, but implement the parsing manually in an interview to demonstrate understanding. This shows you value both correctness and practical engineering.

1. Clarify requirements and edge cases

Ask the interviewer about the exact definition of valid IPv4 and IPv6 addresses, including whether leading zeros are allowed, how to handle compressed IPv6 notation, and if IPv4-mapped IPv6 addresses should be considered IPv6.

2. Design modular validation functions

Outline separate functions for validating IPv4 and IPv6, each returning a boolean. This separation simplifies testing and maintenance, and allows easy extension to other formats.

3. Implement IPv4 validation

Split the string by dots, ensure exactly four parts, each part is a number between 0 and 255, and no leading zeros unless the part is '0'. Consider using a regex or manual parsing.

4. Implement IPv6 validation

Handle the full and compressed forms: split by colons, allow '::' to represent one or more groups of zeros, ensure each group is 1-4 hexadecimal digits, and the total number of groups (including compressed) equals 8. Optionally, handle IPv4-mapped addresses.

5. Combine and classify

Call both validators and return 'IPv4' if the IPv4 validator passes, 'IPv6' if the IPv6 validator passes, and 'Neither' otherwise. Discuss potential ambiguities and how to resolve them.

Key Points to Mention

  • IPv4 format: four decimal octets separated by dots, each 0-255, no leading zeros (except '0').
  • IPv6 format: eight groups of four hexadecimal digits, separated by colons, with '::' compression allowed once.
  • Edge cases: empty string, extra characters, leading/trailing spaces, IPv4-mapped IPv6 addresses (e.g., ::ffff:192.0.2.128).
  • Trade-offs between regex and manual parsing: regex can be concise but hard to read and maintain; manual parsing is more verbose but clearer.
  • Use of built-in libraries (e.g., Python's ipaddress) for production code, but implement manually in interviews to show understanding.
  • Time and space complexity: O(n) time and O(1) space for both validators, where n is the length of the string.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.