Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Restore IP Addresses

Given a string of digits, print every valid IP address that can be formed by inserting three dots. Each part must be between 0 and 255 and must not have leading zeros (except the part 0 itself). Print the addresses in lexicographic order.

Constraints

1 <= len(s) <= 20

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.