Salesforce | Onsite | Reservoir Sampling

Anonymous User
602
Feb 18, 2022

Fill the n*n empty grid with m stars randomly.

Input: 3*3 grid, m =2
//Let 1 represent a star

Output:
000
010
001

According to the interviewer, optimal solution should use a List.

I found a similar problem later on:

https://leetcode.com/discuss/interview-question/algorithms/124759

Comments (0)