Two Sigma Interview Question

Design a random number generator that does not output a number that has already been generated.

Interview Answer

Anonymous

Mar 10, 2020

You could fiddle around with data structures (my initial implementation was using a hashmap for the generated numbers and checking it), but a good solution that I found out after the interview was that you can generate an array with all the numbers up to the max you want to generate, and then just shuffle it.