Amazon Interview Question for Software Developers


Country: United States
Interview Type: Phone Interview




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

How about the entire tournament being represented by 64 bits where each bit corresponds to which team one a particular game (0 means the first team one and 1 means the second team won):
First round- 32 bits
Second round- 16 bits
Third round- 8 bits
Fourth round- 4 bits
Fifth round- 2 bits
Sixth round- 1 bit

Scoring would be simple- XOR the user prediction with reality and count the resulting 0s.

- zortlord July 15, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

brilliant!

- SK July 15, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Neat solution. I think this would be the most efficient one. I propose a small change, an integer for each player to keep track of his score. The score will be +1 or -1 as per the prediction.

- puneet.sohi July 15, 2015 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Your solution just works for one round prediction.
How about all rounds?

- pkushiqiang July 16, 2015 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

ddd

- pkushiqiang July 16, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Your idea works good for one round prediction,
How about all rounds ?

- pkushiqiang July 16, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

The solution I came up with was using an array, but I didn't think of using XOR to calculate the score. I have been thinking if there is a way to find the winner without scoring each fan individually but no luck.

- DVD July 16, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I agree with @pkushigiang that this won't work beyond the first round. Say I guess 00... and it's actually 11..., then in round two I guess 1... <- that's not the correct team. In fact I was completely wrong about which two teams would advance to the second round in the first bracket so anything I guess for the outcome of that match in the second bracket would be incorrect.

I think we'd need 64 bits per round, each team has a bit, 1 means they're still in and 0 means they're out. Last round has 64 bits with 1 bit on for the winning team. Long.bitCount(guess & actual) would score each round for a fan.

- clish July 16, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Wait...this doesn't really work. You don't get points just for guessing whether the first team wins or the second team wins in each matchup. It could be that in a given matchup, you correctly guessed that the first team wins, but since you incorrectly predicted which team it would be from the previous round, you don't get any points.

- Anonymous July 17, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Someone please elaborate.
I did not get the part where fans construct fantasy brackets for their tournament predictions! How is that made done?

- Shank July 18, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Simply Amazing is the only word to describe this approach !!

- Coder July 15, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Fans construct fantasy brackets for their tournament predictions. Someone Please elaborate on this.

- SC July 18, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Well, just like a heap in an array, you can also search that both the previous games were correctly predicted for the rounds after the first round. May be, it can be in the reverse direction - to start with it would be bit 1 (0-based indices) from the left for the final, the next 2 bits for the semi-final, the next 4 for the quarterfinal and so on. When any of the other rounds are being calculated, you need to check the previous rounds are all correct, so it won't be a simple XOR, but still manageable.

- TheCoder July 21, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can we use a map to solve this problem? The keys being the player's identity and value being the scores.

- Hacker360 September 02, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think approach is fine. For all tournament we can 64 bits where each bit is representing one team. Then for each round winner team's bit would be set to 1. So for 6 rounds, we have 6 unsigned short numbers. Then similarly for every FAN, there is a list of 6 numbers which will predict his result in all 6 rounds. Now compare relevant rounds by XOR and if value is 0 assign point for that round else dont do any thing. We will get result in that way.

- Phoneix January 21, 2016 | 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