A valid IP address must be in the form ABCD, where A, B, C and D are numbers from 0 to 255. Numbers cannot be prefixed with 0 unless they are 0.
Input: 25525511135 Output: [“255.255.11.135”, “255.255.111.35”] Explanation: These are the only valid possible IP addresses. Input: "25505011535" Output:  Explanation: We cannot generate a valid IP address with this string.
First we'll put 3 dots on a given string and then try all possible combinations for 3 dots.
Corner case for reality:
For string "25011255255" 25.011.255.255 is not valid as 011 is not valid. 188.8.131.52 is not valid either as you are not allowed to change the string. 250.11.255.255 is valid.
Break the line with & # 39 ;. and then check all corner cases. Check the string size before entering the loop. Create all possible combinations by looping through the line. If the IP address is valid, return the IP address, otherwise just return an empty list.
Below is the implementation of the above approach: