FastPrepHigh-Traffic IPs in a Sliding Window
Problems/High-Traffic IPs in a Sliding Window

High-Traffic IPs in a Sliding Window

Google logoGoogle● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives a stream of server logs in time order, a ten-minute threshold query, a sliding window with a hash map, a linear-time version, and follow-ups on scale and memory. Here the window and threshold are inputs, and we set the endpoint and output-order rules. Our version is about 92% the same as the reported question.

You receive a chronological stream of server requests. The arrays timestamps and ipAddresses describe the same requests, and timestamps[i] is the integer arrival time of ipAddresses[i].

For each IP address, consider every sliding window of the form (t - windowSeconds, t] whose right endpoint t is one of that IP address's request timestamps. An address is high traffic if at least one such window contains strictly more than requestThreshold requests from that address.

Return every high-traffic IP address exactly once, sorted in lexicographic order. Requests with the same timestamp are all inside the same active window.

Process the requests in chronological order without rescanning the full history for every request.

Function

findHighTrafficIps(timestamps: int[], ipAddresses: String[], windowSeconds: int, requestThreshold: int) → String[]

Examples

Example 1

timestamps = [1,2,3,12,13]ipAddresses = ["10.0.0.1","10.0.0.1","10.0.0.1","10.0.0.1","10.0.0.2"]windowSeconds = 10requestThreshold = 2return = ["10.0.0.1"]

At timestamp 3, the window (-7, 3] contains three requests from 10.0.0.1, which is strictly more than the threshold of two.

Example 2

timestamps = [0,10,10,20]ipAddresses = ["x","x","y","x"]windowSeconds = 10requestThreshold = 1return = []

A request exactly windowSeconds before the current timestamp is outside the half-open window. No IP has more than one request in any active window.

Constraints

  • 0 <= timestamps.length == ipAddresses.length <= 200000.
  • 0 <= timestamps[i] <= 10^9, and timestamps is sorted in nondecreasing order.
  • Every IP address is a non-empty string of at most 64 visible ASCII characters.
  • 1 <= windowSeconds <= 10^9.
  • 1 <= requestThreshold <= max(1, timestamps.length).

More Google Onsite Interview questions

  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Transcript Window MetricsSesame · PHONE SCREEN
  • Incident MonitorStripe · OAStripe interview questions
  • Shortest Window with Required CountsOracle · ONSITE INTERVIEWOracle interview questions
  • Count Zero Request ServersSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Sliding-Window Rate LimiterAmazon · ONSITE INTERVIEW
  • Longest Continuous Subarray Within an Absolute-Difference LimitUber · ONSITE INTERVIEWUber interview questions
  • Rate Limiter with Global and Per-User LimitsOpenAI · ONSITE INTERVIEWOpenAI interview questions
  • Sliding-Window Rate LimiterSnowflake · ONSITE INTERVIEWSnowflake interview questions
  • Count Equal Code Pairs Within Distance KInfosys · ONSITE INTERVIEWInfosys interview questions
  • Rate Limiter Sliding Window With Per-Entity LimitsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions

Interview reports that mention this question

  • Google SWE Intern Interviews: 85 Experiences (Part 1 of 8)

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public String[] findHighTrafficIps(int[] timestamps, String[] ipAddresses, int windowSeconds, int requestThreshold) {
        // Write your code here.
    }
}
Checking account…