Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
2
of 2 vote

Odd powers of 3 means multiplying by 9. Hence 1001(base2). Thus we can Shift left 3 positions and add the number.

Num = (Num<<3) + Num

This will reduce the overhead of multiplication of a huge number by 9.

gawk 'BEGIN {
  No=3; 
  power=1; 
  print "1 " No;
} { 
  No = lshift(No,3) + No ;
  power += 2;
  print power " " No;
  }'

- Sumit Ghosh January 17, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Not sure this would work, since leftshif (<<) on a number would only make the number half

- arunraja101 January 26, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Not sure this would work, since leftshift (<<) on a number would only make the number half

- arunraja101 January 26, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

That is right shift what you are talking about.

100(base 2) >> 1 = 10(base 2)
i.e. when 4 is right shifted by 1 place it becomes half.

Thus if you are doing a left shift it will become double.

- Sumit Ghosh January 26, 2012 | 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