Begged Interviewer to let me drop off the Interview | Forward Networks | 6YOE

Experience
6 years
Posted
26 Mar 2026
213 reads

Summary

I struggled with the longest prefix match coding problem in the second round and was unable to solve it, resulting in an unsuccessful interview.

How it went

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<String, String> findNextHops( List prefixEntries, List ipAddresses)

The function should return a mapping of each IP address to the next-hop IP address determined using the longest prefix match.

Example

Prefix entries:

168.19.100.34/32 → 1.1.1.1 168.19.100.0/25 → 1.1.1.2 168.19.100.0/24 → 1.1.1.3 168.19.0.0/8 → 1.1.1.4 0.0.0.0/0 → 1.1.1.5

IP addresses:

168.19.100.34 168.19.100.198 169.0.0.0

Expected output:

168.19.100.34 → 1.1.1.1 168.19.100.198 → 1.1.1.3 169.0.0.0 → 1.1.1.5

Could not Understand what to do, how to do, did my best, but something was off with this question, had to ask interviewer to spare me and wasting his time

Questions asked (1)

  1. 01

    Longest Prefix Match for Policy Based Routing

    Data Structures & Algorithms

    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") and nextHop is the next‑hop IP address.
    • A list of IPv4 addresses.

    Write a function:

    public static Map<String, String> findNextHops(
        List<PrefixEntry> prefixEntries,
        List<String> ipAddresses)
    

    The function should return a mapping of each IP address to the next‑hop IP address determined using the longest prefix match.

    Example

    Prefix entries:

    168.19.100.34/32 → 1.1.1.1
    168.19.100.0/25  → 1.1.1.2
    168.19.100.0/24  → 1.1.1.3
    168.19.0.0/8      → 1.1.1.4
    0.0.0.0/0        → 1.1.1.5
    

    IP addresses:

    168.19.100.34
    168.19.100.198
    169.0.0.0
    

    Expected output:

    168.19.100.34  → 1.1.1.1
    168.19.100.198 → 1.1.1.3
    169.0.0.0      → 1.1.1.5
    

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Forward Networks recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!