FastPrepAccept or Decline Queries
Problems/Accept or Decline Queries

Accept or Decline Queries

Ramp logoRamp● MediumNEW GRADFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report describes a per-IP sliding-window limiter and says rejected requests must not count. It mentions up to 100 million requests and a four-second Python target, without a measured result.

This version preserves the inclusive boundary shown in the existing examples. The editorial discusses dropping expired records and streaming the large-input follow-up; the reported timing is not a runtime guarantee.

The judged core task matches the reported behavior at about 95%.

Process timestamped requests in order. For each request, decide whether to accept it based on how many requests from the same IP were already accepted in the inclusive window [currentTime - timeWindow, currentTime].

  • timestamps[i] is a non-negative decimal timestamp string in milliseconds. Strings preserve timestamps that exceed a Java int.
  • ipAddresses[i] identifies the IP for the same request. Treat these strings as opaque identifiers.
  • Requests are in non-decreasing timestamp order. Two requests from the same IP never have the same timestamp.
  • Accept the request if fewer than limit requests from that IP were accepted in the window; otherwise reject it.
  • Rejected requests do not count toward later limits.

Return one integer for each request in order: 1 for accepted and 0 for rejected.

Large-input follow-up

Consider how to process up to 10^8 requests with a window as large as 10^9 milliseconds. Avoid keeping old request records after they can no longer affect any decision. Discuss streaming the input and decisions when storing the full arrays is too large.

Function

acceptOrDeclineQueries(timestamps: String[], ipAddresses: String[], limit: int, timeWindow: int) → int[]

Examples

Example 1

timestamps = ["1600040547954", "1600040547957", "1600040547958"]ipAddresses = ["127.127.420.312", "127.127.420.312", "127.127.420.312"]limit = 1timeWindow = 3return = [1, 0, 1]

The first request is accepted. The second is exactly 3 milliseconds later, so the first is still in the inclusive window and the second is rejected. At the third request, the first is 4 milliseconds old and has expired. The rejected second request does not count, so the third is accepted.

Example 2

timestamps = ["52245", "52245", "52246", "52247", "52248", "52249", "52253"]ipAddresses = ["00.00.00.15", "00.00.00.42", "00.00.00.15", "00.00.00.15", "00.00.00.42", "00.00.00.15", "00.00.00.96"]limit = 2timeWindow = 3return = [1, 1, 1, 0, 1, 1, 1]

The first three requests are accepted. At time 52247, IP 00.00.00.15 already has two accepted requests in its window, so this request is rejected. IP 00.00.00.42 has room at 52248. At 52249, the accepted request at 52245 has expired, so IP 00.00.00.15 can make another request. The final IP is new.

Example 3

timestamps = ["1000","1005","1010"]ipAddresses = ["1.1.1.1","1.1.1.1","2.2.2.2"]limit = 2timeWindow = 10return = [1,1,1]

The first IP has only one earlier accepted request when its second request arrives. The third request uses a different IP. All three are accepted.

Constraints

  • 1 <= timestamps.length <= 10^8.
  • timestamps.length == ipAddresses.length.
  • Every timestamp is a decimal integer string from 0 through 9223372036854775807.
  • Each IP identifier is non-empty.
  • Timestamps are non-decreasing; timestamps for any one IP are strictly increasing.
  • 1 <= limit <= 10^8.
  • 1 <= timeWindow <= 10^9.

Source note: This source image shows the reported Ramp online-assessment examples for the per-IP sliding-window rate limiter.

More Ramp interview questions

  • Count Overlapping Square PairsOA · Seen Nov 2026
  • Count User Mentions in Chat MessagesOA · Seen Nov 2026
  • Retryable URL MazePHONE SCREEN · Seen Oct 2026
  • Detect Recurring Transactions with Tunable TolerancesONSITE INTERVIEW · Seen Jul 2026
  • Recipe Management SystemOA · Seen Mar 2026
  • Task Manager with Timed AssignmentsOA · Seen Jan 2026
  • Bank Requests with Delayed CashbackOA · Seen Dec 2025
  • Find a User’s Airport from Flight HistoryPHONE SCREEN · Seen Sep 2025
  • Convert Snake Case Variables to Camel CaseOA · Seen Apr 2025
  • Correct Apartment Bedroom CountsOA · Seen Feb 2025

Similar questions at other companies

  • Get Message StatusSalesforce · OASalesforce interview questions
  • Per-Client Sliding-Window Rate LimiterGeneral Motors · OA
  • Per-Domain Request LimiterExpedia · OAExpedia interview questions
  • Per-User Sliding-Window Rate LimiterPayPal · OAPayPal interview questions
  • Incident MonitorStripe · OAStripe interview questions
  • Fixed Window Average and ModeNuro · PHONE SCREENNuro interview questions
  • Rate Limiter with a Sliding Window per ClientStackAdapt · PHONE SCREENStackAdapt interview questions
  • Per-Client API Rate LimiterDocker · PHONE SCREEN
  • Per-Client Sliding-Window Rate LimiterCVS Health · PHONE SCREEN
  • Sliding-Window Rate LimiterAmazon · ONSITE INTERVIEW

Interview reports that mention this question

  • Ramp SWE New Grad OA and Phone Screen: 7 Experiences

Ramp interview experiences

  • Ramp interviews · November 2026
  • Ramp AI Coding Round, Experienced SWE Onsite: 3 Experiences
  • Ramp Mobile and Android Interview Questions: 6 Experiences
All Ramp interview questionsSee Ramp hiring insights
Saved
class Solution {
    public int[] acceptOrDeclineQueries(String[] timestamps, String[] ipAddresses, int limit, int timeWindow) {
      // write your code here
    }

}
Checking account…