java - Generating unique random numbers and check duplicates -
this question has answer here:
i generate 3*6 digits, can form array of 3rows*6cols. don't want duplicated found in column. can anywhere, in same row, in each column, there shouldn't duplicate of same number. there algorithm generating ?
fill matrix column-wise , use set keep track of numbers have used in current column. can use do-while statement each cell, in pseudo-code:
for each column { used = new set each cell in column { { num = generate random number } while (num in used) add num used add num current cell } }
Comments
Post a Comment