SDE Sheet - Generate IP Addresses
source link: https://www.geeksforgeeks.org/videos/sde-sheet-generate-ip-addresses/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Generate IP Addresses
This video is part of the Backtracking section under the GFG SDE Sheet.
In this problem, we are given Given a string S containing only digits, Your task is to complete the function genIp() which returns a vector containing all possible combinations of valid IPv4 IP addresses and takes only a string S as its only argument.
Note: Order doesn't matter. A valid IP address must be in the form of A.B.C.D, where A, B, C, and D are numbers from 0-255. The numbers cannot be 0 prefixed unless they are 0.
For string 11211 the IP address possible are
1.1.2.11
1.1.21.1
1.12.1.1
11.2.1.1
Example :
Input: S = 1111 Output: 1.1.1.1
Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!
Do check out:-
Article: https://www.geeksforgeeks.org/program-generate-possible-valid-ip-addresses-given-string/
Problem: https://www.geeksforgeeks.org/problems/generate-ip-addresses/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK