Interesting question in IP address generation
Anonymous User
691

I was asked a question regarding IP generation between two ip addresses. Suppose we have two ip addresses like 0.0.0.0 and 1.1.1.1, the interviewer asked me to generated all the ip addresses exisiting between these two ips. Upon solving this the interviewer extended the question and asked me if I can generate all ip addresses when a list of ip addressess are given. For example if we have a list like [0.0.0.0, 1.1.1.1, 2.2.2.2]. The interviewer was interested in learning my approach for this problem. For the first case I used back tracking + recursion to solve the problem, but I am stuck in the second part. I suggested backtracking but he suggested there is another elegant approach to this process. what's the best approach to this problem?

Comments (3)