FastPrepRandom Picks Excluding Recent Values
Problems/Random Picks Excluding Recent Values

Random Picks Excluding Recent Values

Google logoGoogle● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report does not give the finite lifecycle or a way to test it with fixed results. Our version is about 91% the same as the reported question.

You are given an array of distinct integer values, an exclusion length k, a requested number of accepted picks picks, and recorded random candidate indices draws.

Process draws from left to right. A candidate index selects values[draws[i]]. Reject that candidate when its value appears among the most recent k accepted values. Otherwise, accept it, append it to the result, and update the recent-value history.

Rejected candidates do not change the recent-value history. Stop as soon as picks values have been accepted and return them in acceptance order.

When k is 0, every candidate is accepted. The input guarantees that draws contains enough acceptable candidates to produce the requested result.

Function

pickWithoutRecent(values: int[], k: int, picks: int, draws: int[]) → int[]

Examples

Example 1

values = [10,20,30]k = 1picks = 4draws = [0,0,1,1,2,0]return = [10,20,30,10]

Accept 10, reject the repeated 10, accept 20, reject the repeated 20, then accept 30 and 10.

Example 2

values = [1,2,3,4]k = 2picks = 5draws = [0,1,0,2,1,3,0]return = [1,2,3,4,1]

After accepting 1 and 2, the next 1 is rejected. After accepting 3, the next 2 is still recent and is rejected.

Example 3

values = [5,7]k = 0picks = 4draws = [1,1,0,1]return = [7,7,5,7]

With k = 0, no accepted value is excluded, so every recorded candidate is returned.

Constraints

  • 1 <= values.length <= 10^5.
  • All values are distinct and satisfy -10^9 <= values[i] <= 10^9.
  • 0 <= k < values.length.
  • 1 <= picks <= 10^5.
  • picks <= draws.length <= 2 * 10^5.
  • 0 <= draws[i] < values.length.
  • The recorded candidates contain enough accepted values to produce exactly picks results.

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

  • Stateful Paginated Fetch NLyft · PHONE SCREENLyft interview questions
  • Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
  • Capital Gains Tax from TradesArcesium · OAArcesium interview questions
  • Incident MonitorStripe · OAStripe interview questions
  • Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • Propagating Fraud DetectorAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
  • Deep Copy a Random-Pointer ListAmazon · ONSITE INTERVIEW
  • Instant-Runoff Voting WinnerWise · ONSITE INTERVIEW
  • Sliding-Window Rate LimiterSnowflake · ONSITE INTERVIEWSnowflake interview questions
  • Escape Room LeaderboardPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions

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
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int[] pickWithoutRecent(int[] values, int k, int picks, int[] draws) {
      // Write your code here.
    }
}
Checking account…