Search⌘ K
AI Features

DIY: Random Pick Index

Explore how to solve the problem of randomly selecting an index of a target value from an array with duplicates, focusing on memory-efficient techniques. Understand how to implement the constructor and pick function to handle large arrays and ensure correct random selection.

Problem statement

In this challenge, you are given an array of integers with possible duplicate values. Your task is to output a randomly picked index of a given target number present in the array. The solution ...