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

Write your Interview Experience or mail it to contribute@geeksforgeeks.org

My Personal Notes arrow_drop_up
Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.