Search⌘ K
AI Features

DIY: Random Pick Index

Explore how to solve the random pick index problem by implementing a memory-efficient algorithm in Swift. This lesson helps you understand techniques to select random indices for a target number within an array containing duplicates, a common topic in coding interviews, particularly for roles at 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 ...