Help the Community

Share your interview experience to help others prepare!

Get the App

Practice on the go! Download our Android app to read experiences anywhere.

forward networks logo

Forward Networks

More Experiences

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

forward networks logo
forward networks
· 6y exp
March 26, 2026 · 0 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.

Full 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 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

Interview Questions (1)

1.

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

📣 Found this helpful? Please share it with friends who are preparing for interviews!

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

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