Amazon Interview Question for SDE1s


Country: india
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
1
of 3 vote

System.currentTimeMillis() % upperbound

- Srikanth May 02, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Beautiful..

- teli.vaibhav May 03, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

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);
}

- Annonymous May 05, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

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.

- FredCycle May 07, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

can you please explain this line
Thnks

- hina June 03, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

There is an excellent, and very short random generator : the XORShift. It passes random generator Diehard tests, and is very concise.
en.wikipedia.org/wiki/Xorshift

- Nitin May 03, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

sha1(current time in ms) -> strip all a-z away and you have a random number.

- y1426i May 09, 2014 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More