Amazon Interview Experience | Set 221
I gave my round 1 amazon. There were two coding questions.
1) Given an integer n in the input, find its next sparse binary numberA sparse binary number is a number whose binary representation does not contain any consecutive 1s.
For eg.
72 is a sparse binary number, because its binary representation (01001000) does not contain any consecutive 1s.
17 is a sparse binary number, because its binary representation (00010001) does not contain any consecutive 1s.
Similarly,
12 is a non sparse binary number, because its binary representation (00001100) contains consecutive 1s.
43 is a non sparse binary number, because its binary representation (00101011) contains consecutive 1s.
Now, given an integer n in the input, find its next sparse binary number. n itself can be sparse or non sparse.
where n >= 0 and n < 2^31
Input 12
Output
16
Explanation
12 is 00001100 and next sparse no. to it is 16 (00010000).
2) You are given heights of n candles.
First day you lit one candle s
Scond day you need to lit two candles
Third day you need to lit three candles
..........
........
till possible.
After lighting candles the height of candles deduced by 1 each day.You can also extinguish any candle you want but only at the end of day.
So you need to tell the maximum number number of days , you can carry on lighting the candles.
Example : there are three candles of heights {2 , 2 ,2 }
Answer : 3
1.You light first candle on day one. heights -> {1,2,2}
2.You light second and third and extinguish first one . heights ->{1, 1,1}
3.You light all the candles. heights -{0,0,0}
Hope it helps aspirants.
Online mcq, there were around 20 and 13-14 were from geeksquiz.com
If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Recommended Posts:
- Amazon Interview Experience | Set 167 (SDE I for 1 year 6 months experience)
- Amazon Interview Experience | Set 242 (1 Year Experience)
- Amazon Interview Experience | Set 241 (1.5 years experience)
- Amazon Interview Experience | Set 243 (2.5 Years Experience)
- Amazon Interview Experience | 401 (3+Years Experience for SDE II)
- Amazon Interview Experience | Set 391 (SDE-2, 5.5 years Experience)
- Amazon Interview Experience (For Experience - 2.8 yrs) | SDE 1
- Amazon Interview Experience | Set 248 (4.8 Yrs Experience for SDE II)
- Amazon interview Experience | Set 409 (For SDE-I)
- Amazon interview Experience | 411 (SDE-1)
- Amazon interview experience | Set 396 (For SDE-2)
- Amazon Interview Experience | Set 392 (For SDE 2)
- Amazon Interview Experience | Set 373 (For SDE 2)
- Amazon Interview Experience | Set 372 (For SDE II)
- Amazon Interview Experience | Set 400 (For SDE 2)



