Forward Networks Software Engineer Interview: Longest Prefix Match Problem
Interview Experience
2 Rounds Round 1 Onilne Assesment Round 2 A network device maintains Policy Based Routing (PBR) entries. Each entry contains an IP subnet in CIDR notation and a corresponding next-hop IP address. When
Full Details
2 Rounds Round 1 Onilne Assesment Round 2 A network device maintains Policy Based Routing (PBR) entries. Each entry contains an IP subnet in CIDR notation and a corresponding next-hop IP address. When a packet with a destination IP arrives, the device must determine the next-hop based on the Longest Prefix Match rule. If multiple subnets match the destination IP, the subnet with the largest prefix length must be selected. If no subnet matches, the default route (0.0.0.0/0) should be used. You are given: A list of PBR entries represented by a class PrefixEntry, where: ipSubnet is a subnet in CIDR format (e.g., "168.19.100.0/24") nextHop is the next-hop IP address. A list of IPv4 addresses. Write a function: public static Map