PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Evaluate IP Access Rules

Last updated: Apr 12, 2026

Quick Overview

This question evaluates knowledge of IPv4 addressing, CIDR subnet matching, and access-control rule resolution, assessing competency in bitwise address reasoning, prefix-length precedence, and rule tie-breaking.

  • hard
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Evaluate IP Access Rules

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given a list of IPv4 access-control rules. Each rule consists of: - an action: `allow` or `deny` - a CIDR block such as `192.168.0.0/16` You are also given a target IPv4 address such as `192.168.1.25`. Determine whether the target IP should be **allowed** or **denied**. Use the following rule semantics so the problem is fully specified: 1. A rule matches if the target IP belongs to that CIDR block. 2. If multiple rules match, the rule with the **longest prefix length** takes precedence. 3. If multiple matching rules have the same prefix length, the **later** rule in the input overrides the earlier one. 4. If no rule matches, return `deny`. Implement a function that takes a list of rules and one IPv4 address and returns the final decision. You may assume all inputs are valid IPv4 addresses and valid CIDR blocks, with prefix lengths from 0 to 32.

Quick Answer: This question evaluates knowledge of IPv4 addressing, CIDR subnet matching, and access-control rule resolution, assessing competency in bitwise address reasoning, prefix-length precedence, and rule tie-breaking.

Related Interview Questions

  • Implement Datacenter Router Commands - Amazon (hard)
  • Replace Delimited Tokens in a String - Amazon (medium)
  • Minimize Circular Redistribution Cost - Amazon (medium)
  • Find the Most Common Visit Pattern - Amazon (hard)
  • Maximize Value Under a Budget - Amazon (medium)
Amazon logo
Amazon
Feb 17, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
11
0

You are given a list of IPv4 access-control rules. Each rule consists of:

  • an action: allow or deny
  • a CIDR block such as 192.168.0.0/16

You are also given a target IPv4 address such as 192.168.1.25.

Determine whether the target IP should be allowed or denied.

Use the following rule semantics so the problem is fully specified:

  1. A rule matches if the target IP belongs to that CIDR block.
  2. If multiple rules match, the rule with the longest prefix length takes precedence.
  3. If multiple matching rules have the same prefix length, the later rule in the input overrides the earlier one.
  4. If no rule matches, return deny .

Implement a function that takes a list of rules and one IPv4 address and returns the final decision.

You may assume all inputs are valid IPv4 addresses and valid CIDR blocks, with prefix lengths from 0 to 32.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.