Software Engineer Developer Interview Questions

466,326 software engineer developer 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 101 - 110 interview questions

See Interview Questions for Similar Jobs

Glassdoor has 466,326 interview questions and reports from Software engineer developer interviews. Prepare for your interview. Get hired. Love your job.