Map IP address ranges to cities
Anonymous User
1378

Interview Question:

If there are multiple IP addresses, how would you classify them into different cities that they belong to. If range for New York is: 134.123.65.5 - 135.123.124.21. and then the IP address is 134.126.232.12 does not belong to NY and IP address 134.123.89.45 does belong to NY.

Approahes:

  1. Create a tree structure for each of the dotted sections and leaf nodes would be cities
  2. Segment/Interval tree.

If someone could help me with python implementation, that would be great!

Comments (3)