Amazon Interview Question for Financial Software Developers


Country: United States




Comment hidden because of low score. Click to expand.
39
of 41 vote

Ask the class to stand up and make pairs, if one student is left out write '1' else write 0. tell the left out student to sit down and ask one person in each group to sit down. Repeat the process and append '1' or '0' to your number, until no student is left standing. You will get the binary representation of the number of students in reverse order.
Eg: lets say there are 23 students in the class
Students standing 23 11 5 2 1 0
Solution 1 1 1 0 1 0

we have a string 111010, and the binary representation of 23 is 010111.
This is just using divide and conquer O(lg n)

- Luc March 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Good one...!!

- NP March 19, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

solution is so nice

- VMK April 11, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

solution is so nice

- VMK April 11, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Excellent Thinking Great job man

- KPE May 31, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

its nice

- eshank.rastogi June 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

excillent too good

- eshank.rastogi June 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Hello Mrs Dear eshank.rastogi ,
Hope you are satisifed now.

- topcoder June 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

no doubt answer is awsme..but u can't ask the students to pairup or something like that...its your work to count...
otherwise i will say that just start the counting from one corner to last....:D

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

Nicely done..

- marv July 30, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

nice solution..the same can actually be replicated by grouping 'n' number of students.
e.g take 4 students as a pair and find the total students%4..Then
total students/4 is used as the next input..
in simple terms n-ary division and find the decimal equiavlents
of the remainder in reverse form

- za007 August 07, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Superb.....

- Dinakaran August 13, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can anybody explain how come this is the quickest possible solution.

- trilok.arora September 28, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

number rows * (number of column - 1) + number of rows in last column - number of empty seats

- Sandeep Mukherjee March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Or I will just check the attendance sheet ;) O(1) time

- Sandeep Mukherjee March 13, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Is it possible to check the attendance in O(1) ? I guess we need to sequencely count number of P's (for present) in the array .and that can be done in 0(n) .

- Rachit March 13, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Sandeep : xD

- imrhk July 21, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Ask first row people to count number of students in their respective column.... and sum all columns...

- Anonymous March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

for each column, one student sitting at front start counting towards end and another student sitting at the end start counting the number of students towards front, they will meet at middle and add both and keep with one student... finally sum all column count.

- Anonymous March 13, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Have each person stand up and find a partner.
If there is a single have him stand alone in the front of the class.
Assign one of the partners in each couple to remember the number 2 and have the other sit down.
Repeat this process and now have the person remember 4, then 8, then 16 and so forth until there is only one person standing.
Add 1 to the total if single person exists, and you have a O(lg(n)) solution.

- Ron March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Perhaps the best solution here.

- eugene.yarovoi March 13, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Ask 1 student to go out of the class, then 2 students go out of the class, then 4 students, then 8 students... its a variation of binary search

- Anonymous March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

obviously...

- yuhes March 21, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Tell the class to tell absent friends name

- Amit Sharma March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think that we should know the capcity of the classroom, then just count the number of empty seat if most students show up

- Anonymous March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think that we should know the capcity of the classroom, then just count the number of empty seat if most students show up

- Anonymous March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think that we should know the capcity of the classroom, then just count the number of empty seat if most students show up

- Anonymous March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think that we should know the capcity of the classroom, then just count the number of empty seat if most students show up

- Anonymous March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Ask every student to initialize value to: 1
Ask Every Nearest neighbour his no. and add his no. to yours both share the added no.
The highest at end is total no of students.

- Gyan March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Ask every student to initialize value to: 1
Ask Every Nearest neighbour his no. and add his no. to yours both share the added no.
The highest at end is total no of students.

- Gyan March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ASk students to stand like a Binary Tree. Total=2^n-1
If Last Level is not filled. Make them start a new Binary Tree..so on

- Coder_Jack March 15, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ASk students to stand like a Binary Tree. Total=2^n-1
If Last Level is not filled. Make last level students only to start a new Binary Tree..so on

- Coder_Jack March 15, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If there are N number of seats for M number of students ie, one for each students, which means M should be equal to N. Say if N-1 seats are occupied then one student is absent, if N-2, two students are absent and so on...

- sidh March 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Just tell the class that on the day of the count you will give an exam where they have to write their name or else they get -100% on their final grade.

On the day of the count you subtract 0 from the the enrollment count. muhahahah!

- Mr. Tough April 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Just tell the class that on the day of the count you will give an exam where they have to write their name or else they get -100% on their final grade.

On the day of the count you subtract 0 from the the enrollment count. muhahahah!

- Mr. Tough April 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I would ask students to call out their roll numbers from last to first. ;) its takes only O(1) LOL. I am genius am i not?

- Kashif Khan August 22, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Tell the students: "Anyone who is absent today raise their hand."
Then count the number of raised hands, lets name it p.
Then subtract p from the total number of students.
Then you will have :p

- yasser.yag January 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Any idea how to do it in O(1)??

- Anonymous October 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

ask teacher :P

- GADHAAPRASAAD May 28, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

i will ask for the last roll number..... :)

- Raman April 06, 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