← Questions

Insert, delete and get random in O(1) with duplicates

0
SnowflakeCodingLast asked Sep 2026

A coding interview question asked in Snowflake's coding round, last asked Sep 2026. It tests hash maps, arrays and randomization.

Design a collection of integers that allows duplicates and supports insert, remove and a random pick, each in average O(1) time. The random pick returns a value with probability proportional to how many copies of it the collection holds.

Sign in to unlock this question

The full prompt, the worked answer and your own canvas or code with the AI tutor. New accounts get 5 credits: each one unlocks a question for good.

Where it's asked

  • Snowflake · Coding · Last asked Sep 202660 min · Live coding; senior loops may agree a small storage component together, then build it

What it tests

hash maps · arrays · randomization · data structure design

Your code and the AI tutor open when you unlock this question.