FastPrepSliding-Window Frequency Snapshots
Problems/Sliding-Window Frequency Snapshots

Sliding-Window Frequency Snapshots

Google logoGoogle● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report describes a HashMap plus sliding-window frequency-count task, but leaves out the exact output shape, the order, and the input limits. Our version is about 75% the same as the reported question.

Given an integer array nums and a fixed windowSize, report the frequency of every distinct value in every contiguous window.

Return one row [windowStart, value, count] for each distinct value in each window. Process windows by increasing windowStart; within one window, order rows by increasing value.

Update the frequency state as the left and right edges move instead of recounting every window from scratch.

Function

windowFrequencies(nums: int[], windowSize: int) → int[][]

Examples

Example 1

nums = [1,2,1,3]windowSize = 3return = [[0,1,2],[0,2,1],[1,1,1],[1,2,1],[1,3,1]]

The first window is [1,2,1]; the second is [2,1,3]. Each window contributes rows sorted by value.

Example 2

nums = [5,5,5]windowSize = 2return = [[0,5,2],[1,5,2]]

Both length-two windows contain only value 5, with frequency two.

Example 3

nums = [-1,2]windowSize = 1return = [[0,-1,1],[1,2,1]]

A size-one window produces exactly one frequency row.

Constraints

  • 1 <= nums.length <= 500.
  • -1000000 <= nums[i] <= 1000000.
  • 1 <= windowSize <= nums.length.
  • The total number of returned rows is at most 250000.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 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
  • 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

  • Count Zero Request ServersSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
  • Earliest Hour with Frequent Badge AccessIntuit · OAIntuit interview questions
  • Detect Security Attacks from Network LogsFireworks AI · PHONE SCREEN
  • Smallest Range Covering Elements from K ListsSnap Inc. · PHONE SCREENSnap Inc. interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Group AnagramsAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Shortest Window with Required CountsOracle · ONSITE INTERVIEWOracle interview questions

Interview reports that mention this question

  • Google L3 New Grad SWE Interview Questions: 1 Experience

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 int[][] windowFrequencies(int[] nums, int windowSize) {
        // write your code here
    }
}
Checking account…