Search⌘ K
AI Features

DIY: Random Pick Index

Explore how to implement a memory efficient solution for randomly selecting an index of a target number from an array with duplicates. This lesson helps you understand algorithms that handle large data efficiently while preparing you for interview problems similar to those faced by tech companies like Amazon.

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 ...