MEDIUMasked at 15 companies

Restore IP Addresses

A medium-tier problem at 53% community acceptance, tagged with String, Backtracking. Reported in interviews at Arista Networks and 14 others.

Founder's read

Restore IP Addresses hits your assessment and you blank. You have a string of digits with no dots, and you need to insert exactly three dots to form valid IP addresses. Arista Networks, TikTok, Microsoft, Cisco, and Oracle all ask this. The problem looks deceptively simple until you realize you're building a constrained search tree: each segment must be 1 to 3 digits, no leading zeros except standalone 0, and no value exceeds 255. Half of candidates miss the validation logic and time out on invalid branches. StealthCoder solves this in seconds if you hit it live and the pattern isn't clicking.

Companies asking
15
Difficulty
MEDIUM
Acceptance
53%

Companies that ask "Restore IP Addresses"

If this hits your live OA

Restore IP Addresses is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.

Get StealthCoder
What this means

This is a backtracking problem disguised as string manipulation. The trap is trying to brute force all possible dot placements without pruning invalid IP segments early. The winning approach: recursively try placing the next dot at positions 1, 2, or 3 characters ahead, validate each segment before recursing deeper, and backtrack when a segment violates the rules (leading zeros, value over 255, or empty). Most candidates hardcode the validation inline and lose points on clarity or reusability. The key insight is recognizing this as a constrained permutation problem where backtracking prunes the search space hard. String and Backtracking are the exact topic pair here, and they intersect cleanly: you're backtracking through placement decisions, not values. If you freeze during the assessment, StealthCoder surfaces a clean recursive skeleton and the exact validation conditions, letting you code it fast.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Restore IP Addresses recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Restore IP Addresses interview FAQ

Is Restore IP Addresses really a medium?+

The acceptance rate sits at 53%, which is middle of the road. The problem isn't algorithmically hard, but the validation rules trip people up. Getting all edge cases right (leading zeros, segment bounds, exactly four octets) is where time leaks. If you nail backtracking fundamentals, it's easier than the acceptance rate suggests.

Do I need to return all valid IPs or just count them?+

Return all valid IP addresses as strings. The output is a list. This matters because you can't just check existence; you must reconstruct the original string with dots inserted. That reconstruction step is where sloppy code crashes.

What's the trick to avoiding leading zeros?+

A segment starting with '0' is only valid if it is exactly '0' by itself. So '01' is invalid, '0' is valid, '192' is valid. Check segment length and first character: if it starts with '0' and length > 1, prune immediately. This saves exponential backtrack waste.

How does this relate to the backtracking topic?+

Backtracking is core. You try placing a dot after 1, 2, or 3 characters, recursively build the rest, and undo (backtrack) if you hit a dead end. Without aggressive pruning via validation, the search tree explodes. It's a textbook constrained permutation search.

Will I see this at Arista, TikTok, or Microsoft?+

Yes, all three have asked it. It's a medium-difficulty bar for on-site and coding assessments. It's not a trick question, but it does expose whether you code cleanly under time pressure and handle edge cases without panic. A clean solution here builds confidence.

Want the actual problem statement? View "Restore IP Addresses" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.