FastPrepBounded IPv4 Filter
Problems/Bounded IPv4 Filter

Bounded IPv4 Filter

Amazon logoAmazon● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Amazon full-time phone screen. The report gives three operations on a pool of IPv4 addresses, a limit of 128 entries, and a small Linux setup. We chose the starting state, what happens when the pool is full, and the input rules. Our version is about 90% the same as the reported question.

Build a pool of IPv4 addresses that holds at most 128 different addresses. The pool lets you add an address, remove an address, and check whether an address is in it right now.

You are given two arrays of the same length, operations and addresses. Start with an empty pool and go through the entries in order. Entry i applies operations[i] to addresses[i].

  • add_ip: if the address is already in the pool, nothing changes. Otherwise, add it only if the pool holds fewer than 128 different addresses. If the pool is full, skip the addition and keep every stored address.
  • remove_ip: remove the address if it is in the pool. Removing an address that is not there changes nothing.
  • check_ip: report true if this exact address is in the pool right now, and false otherwise.

Return the results of the check_ip operations only, in the order they happen. Adding and removing give no output. If there are no checks, return an empty boolean array.

Every address is a valid IPv4 address written the standard way: four numbers from 0 through 255, joined by dots. No part has a leading zero, except a part that is just the digit 0. Every address from 0.0.0.0 through 255.255.255.255 can be stored in the pool. Compare whole addresses only. There are no subnets, prefixes or wildcard rules.

Memory and implementation trade-offs

The interview was set on a small Linux system that stores at most 128 records. Think about how to keep the pool small in memory, and explain the time and memory cost of the data structure you pick. This exercise sets no language-specific memory limit and does not require one particular structure.

Function

processIpOperations(operations: String[], addresses: String[]) → boolean[]

Examples

Example 1

operations = ["check_ip","add_ip","check_ip","add_ip","remove_ip","check_ip"]addresses = ["10.0.0.1","10.0.0.1","10.0.0.1","10.0.0.1","10.0.0.1","10.0.0.1"]return = [false,true,false]

The first check finds an empty pool. After adding 10.0.0.1, the next check returns true. Adding the same address again does not create another copy, so one removal makes the final check return false.

Example 2

operations = ["add_ip","add_ip","remove_ip","check_ip","check_ip","check_ip"]addresses = ["0.0.0.0","255.255.255.255","128.0.0.0","255.255.255.255","128.0.0.0","0.0.0.0"]return = [true,false,true]

The two added addresses are the lowest and the highest possible, and both stay in the pool, so their checks return true. The address 128.0.0.0 was never added, so removing it changes nothing and its check returns false. The output is [true,false,true].

Example 3

operations = ["add_ip","remove_ip"]addresses = ["192.168.1.1","192.168.1.1"]return = []

There are no check_ip operations, so the output is empty.

Constraints

  • 0 <= operations.length = addresses.length <= 10^4.
  • Every operation is add_ip, remove_ip, or check_ip.
  • Every address uses the standard IPv4 format described above.
  • The pool contains at most 128 different addresses after every operation.
  • Operations run one after another, and each call starts with a new empty pool.

More Amazon Phone Screen questions

  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Search in a Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Spread Through a GridPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Consistent-Hash Packet RouterPHONE SCREEN · Seen Nov 2026
  • Count Connected ComponentsPHONE SCREEN · Seen Nov 2026
  • Second Largest Distinct ElementPHONE SCREEN · Seen Nov 2026
  • Task SchedulerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Count Distinct Underwriting PII ValuesAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
  • SimpleRDD Multiset IntersectionDatologyAI · PHONE SCREEN
  • Vehicle Maintenance Event ReadinessWaymo · PHONE SCREENWaymo interview questions
  • Summarize the Latest Event for Each DeviceOneTrust · PHONE SCREEN
  • Project JSON Fields into a Target FormatBooking.com · PHONE SCREEN
  • Employee Training StatusVanta · PHONE SCREEN
  • Select Object by Key ExtremeBridge · PHONE SCREENBridge interview questions
  • Group Names by DepartmentMastercard · PHONE SCREENMastercard interview questions
  • Badge Records Without a MatchWhatNot · PHONE SCREENWhatNot interview questions
  • AI Role: Collection with Add and Remove OperationsApple · PHONE SCREENApple interview questions

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public boolean[] processIpOperations(String[] operations, String[] addresses) {
        // Write your code here.
    }

}
Checking account…