Amazon Interview Question
SDE1sCountry: india
Interview Type: In-Person
i doubt if this is anywhere close to good random number generators
int upperbound = 12571;
for(int i=0;i<20;i++){
System.out.println(System.currentTimeMillis() % upperbound);
}
Not really that beautiful if you're going to call it often and with a constant time between calls. More like a sequence generator with tons of dupes. Try running that in a tight loop for like a 1000 iterations.
The XORshift is much better.
System.currentTimeMillis() % upperbound
- Srikanth May 02, 2014