## Amazon Interview Question for Software Engineer / Developers

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

One possible solution can be WBBWWWB with the most optimised approach.

Cheers!!

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

paint like BWBWWBWWWB ......

how to generate two or more W ???
Sol : After painting by W leave some space without paint. Again paint with W.

Comment hidden because of low score. Click to expand.
0

I think this solution is correct.

Is there any other solution?

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

Consider 8 sectors on the disk. Paint 4 consecutive sectors with one paint, say White. Then paint one adjacent sector with Black paint. Then the next adjacent sector to this one with White paint and the remaining two sectors with Black paint.

So the disk now looks like ....W W W W B W B B... in a circular fashion.

Once you can see a sequence having 4 consecutive whites, you can tell which direction the disk is spinning.

After 4 whites, if you get one black and then one white, it is spinning in the clockwise direction.

After 4 whites, if you get 2 blacks and one white, it is spinning in the anti-clockwise direction.

Comment hidden because of low score. Click to expand.
0

Oops ! I have correction in the last two lines in my answer:
So the disk now looks like ....W W W W B W B B... in a circular clockwise fashion.

I meant After 4 whites, if you get one black and then one white, it is spinning in the ANTI-clockwise direction.

After 4 whites, if you get 2 blacks and one white, it is spinning in the Clockwise direction.

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

I dont know but I assume to color an arrow like structure having a tail and a head. Color the head ">" in black and tail ">" in white. Now while the CD is revolving, if the tail follows head its Clockwise and if Head follows Tail its anti-clockwise.

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

changing the icons like Head will be like a tilted triangle and tail like an greater than sign ">"

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

hi ck
m sorry .... i think your answer is not correct because how would a sensor come to know whether color sign is > or <. sensor would give just give output same in both the cases.

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

I've verified that WWBBBWBW is one of the correct answer.
If we use binary, the equivalent question is:
" find an eight digital binary string where the circular left shift and the circular left shift for the inverse string are different."

This brings me to think:
" Is there an invariant while doing the left shifting? (no matter how we do circular left shift on this string, we can apply some logical operation to that binary string and get an invariant) while inverting that string changes this invariant? "

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

I have another idea to add

you can have painting pattern like this.
B W B&W
the last one is the mix of black and white.Even if the sensor cant sense that color,the direction can be found.
If clock wise B W _ B W _
if anti clock wise W B _ W B _
Is this ok?

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

Assign uniques codes to clockwise and counter-clockwise. Whichever one appears will indicate direction of spin.

This problem is analogous to finding Endianess.

Comment hidden because of low score. Click to expand.
0

I got this question in cisco....

paint with white and black each color is painted only once...

say u split the cd into 8 sectors.... pain the first sector white and second sector black...
if it is rotating clockwise... u will see the white first and then black... if it is anticlockwise... u will see black with an interval of 6 sectors and then u will see white...
I know i have not explained my solution clearly.. but i guess u guys are intelligent enough to understand.

Comment hidden because of low score. Click to expand.
0

Yeah, we are intelligent enough to understand how dumb you are!

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

may be we can have a sequence like bwbwwbwwwbwwwwbwwwww.......
so if see W's increasing then we can have it as one direction
and if we see them decreasing then another direction

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

IMHO VPs answer is the best one and simple to understand as well...thanx vp..

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

Blanks are unnecessary. I found that the easiest way is to paint it as BWBWWB.
If the sensor detect BWWBWB or BWBBWW, the CD runs the opposite direction.

Comment hidden because of low score. Click to expand.
0

i think this is the simplest solution...

Comment hidden because of low score. Click to expand.
0

hey you two guys rock buddy...awesome answers..
jobseeker and jobgiver, both of you are selected for the position of SE@Amazon,NY...just mail me your bio : katherine.ny@amazone.com

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

paint B at any place paint R 90 deegre from B(behind B), place the sensor digonaly opposit of cd, black sensor should be on top of B,
let say t time for one complet circule if Red sensor will be recived a match in 3t/4 then clockwise else counter clockwise

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

could this be a possible solution (assuming it is necessary to paint entire cd with paint so as to
function as a protective coating of some sort ):-
8 sectors:
BWBBWBBBWBWBBWBBBW
becomes BBWBWBBBWBBWBWBBBW IN THE OTHER DIRN.
PLS REPLY AS IM IN MY 2ND YEAR AND NEED PRACTISE.

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.

### 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.