O70

Restore IP Addresses

Mid / Senior Engineer
Target Time: 25 - 35 Minutes
Type: ARRAY

Problem Statement & Objective

A valid IP address consists of exactly four integers separated by single dots. Given a string s containing only digits, return all possible valid IP addresses.

Function Signature (Python)

restore_ip_addresses(s: str) -> list[str]

Input & Output Contract

Output Rule:Geçerli IP adresleri listesi (sıralı).

System Constraints

1 <= s.length <= 20
s yalnızca rakamlar içerir

Example Execution Walkthrough

s = '25525511135' -> ['255.255.11.135', '255.255.111.35']
s = '0000' -> ['0.0.0.0']

Example Test Scenarios (3)

Example 1
Input:["25525511135"]
Expected Output:["255.255.11.135","255.255.111.35"]
Example 2: Dört Sıfır
Input:["0000"]
Expected Output:["0.0.0.0"]
Example 3
Input:["101023"]
Expected Output:["1.0.10.23","1.0.102.3","10.1.0.23","10.10.2.3","101.0.2.3"]
Loading Python Editor...
Input Parameters
[
  "25525511135"
]
Expected Output
[
  "255.255.11.135",
  "255.255.111.35"
]