FastPrepRandom Pick Index with Recorded Draws
Problems/Random Pick Index with Recorded Draws

Random Pick Index with Recorded Draws

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names a well-known problem by how it sounds, in the Bloomberg new-grad phone screen. One exact output cannot check randomness. So our version records each uniform reservoir draw, and the method stays one pass with constant space.

Simulate one call to Random Pick Index for target in nums using recorded random draws.

Visit target occurrences from left to right. For the c-th occurrence, draws[c - 1] is an integer from 0 through c - 1. Replace the currently selected index with this occurrence's index exactly when that recorded draw is 0.

Return the final selected index.

Function

pickIndex(nums: int[], target: int, draws: int[]) → int

Examples

Example 1

nums = [1,2,3,3,3]target = 3draws = [0,1,0]return = 4

Index 2 is selected first, index 3 is skipped, and the final zero draw replaces the choice with index 4.

Example 2

nums = [5]target = 5draws = [0]return = 0

The sole occurrence must be selected.

Example 3

nums = [2,2,2,2]target = 2draws = [0,0,2,1]return = 1

The second occurrence replaces the first; later nonzero draws keep index 1.

Constraints

  • 1 <= nums.length <= 200000.
  • -10^9 <= nums[i], target <= 10^9.
  • target appears at least once.
  • draws.length equals the number of target occurrences.
  • For the zero-based draw index j, 0 <= draws[j] <= j.

More Bloomberg LP Phone Screen questions

  • Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Customer Bootstrap APIDoorDash · PHONE SCREEN · ONSITE INTERVIEWDoorDash interview questions
  • 2D Convolution Layer Forward PassWaymo · PHONE SCREENWaymo interview questions
  • Concurrent Discounted Card PurchasesBrex · PHONE SCREEN
  • Ordered IP FirewallDatabricks · PHONE SCREENDatabricks interview questions
  • Logger Rate Limiter with Every-Arrival HistoryGoogle · PHONE SCREENGoogle interview questions
  • Generic Stack Operation SequenceArista Networks · PHONE SCREEN · ONSITE INTERVIEWArista Networks interview questions
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Sliding Window Attention over a KV CacheNVIDIA · PHONE SCREENNVIDIA interview questions
  • Determine the Winner of Three-Card HandsOpenAI · PHONE SCREENOpenAI interview questions
  • Propagating Fraud DetectorAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int pickIndex(int[] nums, int target, int[] draws) {
        // Write your code here.
    }

}
Checking account…