Tap here to switch tabs
Problem
Submissions
Solution

Solution: Restore IP Addresses

Statement

Naive approach

The naive approach would be to check all possible positions of the dots. Because an IP address requires inserting three dots, and if the input string contains 1212 digits, then there are 1111 possible positions between the digits where a dot can be placed. So, we initially have 1111 choices for the first dot, then 1010 choices for the second dot, and 99 choices for the third dot. This results in at most 11×10×9=99011 × 10 × 9 = 990 ...

Tap here to switch tabs
Problem
Submissions
Solution

Solution: Restore IP Addresses

Statement

Naive approach

The naive approach would be to check all possible positions of the dots. Because an IP address requires inserting three dots, and if the input string contains 1212 digits, then there are 1111 possible positions between the digits where a dot can be placed. So, we initially have 1111 choices for the first dot, then 1010 choices for the second dot, and 99 choices for the third dot. This results in at most 11×10×9=99011 × 10 × 9 = 990 ...