Desarrollador Web Java Interview Questions

711,009 desarrollador web java interview questions shared by candidates

You are given an n by n array filled with '0's, and you have to set randomly X number of '1's in that array. Looping and generating x random number doesn't work as you might get the same random number (especially as X gets closer to n*n, collisions will become more likely in which case you'll loop for a very long time before filling all the '1's). All positions must have the same probability to get selected, and the array might be huge.
avatar

Software Engineer

Interviewed at Google

4.4
Jan 29, 2015

You are given an n by n array filled with '0's, and you have to set randomly X number of '1's in that array. Looping and generating x random number doesn't work as you might get the same random number (especially as X gets closer to n*n, collisions will become more likely in which case you'll loop for a very long time before filling all the '1's). All positions must have the same probability to get selected, and the array might be huge.

Viewing 151 - 160 interview questions

Glassdoor has 711,009 interview questions and reports from Desarrollador web java interviews. Prepare for your interview. Get hired. Love your job.