Timer is Running

Generate IP Addresses
Submissions: 6505   Accuracy:


  Difficulty: Medium   Marks: 4

Given a string S containing only digits, Your task is to complete the function genIp() which returns a vector containing all possible combination of valid IPv4 ip address and takes only a string S as its only argument.
Note : Order doesn't matter.

For string 11211 the ip address possible are

The first line of input will contain no of test cases T. Then T test cases follow . Each test case will contains a string S

For each test case, print the ip addresses in sorted order. You don't need to print it, printing is done by driver code.

Your Task:
Your task is just to complete the function genIp().

S only contains digits(i.e. 0-9)

Example(To be used only for expected output):



Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harshit Sidhwa
Author: Shubham Joshi 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.