Search⌘ K
AI Features

DIY: Random Pick Index

Explore how to build a memory efficient solution in Ruby to randomly select an index for a target value from a large array with duplicates. Understand the implementation of a pick function inside a Solution class to tackle real-world interview problems similar to those asked by 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 ...