Restore IP Addresses
Updated
Problem statement
Given a string digits containing only decimal digits, return every valid IPv4 address obtained by inserting exactly three dots. Return the addresses in lexicographic order.
Each segment must be from 0 through 255 and cannot have a leading zero unless it is exactly 0.
Function
restoreIpAddresses(digits: String) → List<String>Examples
Example 1
digits = "25525511135"return = ["255.255.11.135","255.255.111.35"]Example 2
digits = "0000"return = ["0.0.0.0"]Constraints
1 <= digits.length <= 20.
More Motive Onsite Interview questions
- Group AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
- Longest Equal-Zero-One SubarrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
- Maximum Weighted Sum After Left RotationsONSITE INTERVIEW · Seen Jan 2026
- Valid Parenthesis StringPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
- Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Dec 2025
- Target Triplet SumONSITE INTERVIEW · Seen Dec 2025
- Validate IP AddressONSITE INTERVIEW · Seen Dec 2025
- Generate Palindromic PermutationsONSITE INTERVIEW · Seen Dec 2025
- Minimum Swaps to Group Circular OnesONSITE INTERVIEW · Seen Dec 2025
- Staircase Search In A Sorted MatrixONSITE INTERVIEW · Seen Dec 2025
Similar questions at other companies
- Generate Strings of Length at Least ThreeMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions
- Insert Addition and Multiplication OperatorsPinterest · ONSITE INTERVIEWPinterest interview questions
- Enumerate All SubsequencesInfosys · ONSITE INTERVIEWInfosys interview questions
- Generate ParenthesesAmazon · ONSITE INTERVIEW
- Maximum Unique-Character Word SubsetMeta · ONSITE INTERVIEWMeta interview questions
- Generate All Valid Word AbbreviationsSalesforce · ONSITE INTERVIEWSalesforce interview questions
- Phone Keypad Letter CombinationsGoogle · ONSITE INTERVIEWGoogle interview questions
- Generate ParenthesesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Permutations of Character PositionsPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
- Letter Combinations of Phone DigitsCapital One · ONSITE INTERVIEWCapital One interview questions