Software Engineer Applications Developer Interview Questions

664,898 software engineer applications 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 121 - 130 interview questions

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