|
4 | 4 |
|
5 | 5 | | Current Status| Stats |
|
6 | 6 | | :------------: | :----------: |
|
7 |
| -| Total Problems | 72 | |
8 |
| -| Current Streak | 52 | |
9 |
| -| Longest Streak | 52 ( August 17, 2015 - October 7, 2015 ) | |
| 7 | +| Total Problems | 73 | |
| 8 | +| Current Streak | 53 | |
| 9 | +| Longest Streak | 53 ( August 17, 2015 - October 8, 2015 ) | |
10 | 10 |
|
11 | 11 | </center>
|
12 | 12 |
|
@@ -64,6 +64,21 @@ Include contains single header implementation of data structures and some algori
|
64 | 64 | | How many bit flip operation would require to convert number A to B. | [countNumberOfBitFlips.cpp](bit_manipulation/countNumberOfBitFlips.cpp)|
|
65 | 65 | | Given a number x and two positions (from right side) in binary representation of x, write a function that swaps n right bits at given two positions and returns the result. It is also given that the two sets of bits do not overlap.|[swapSetOfBits.cpp](bit_manipulation/swapSetOfBits.cpp)|
|
66 | 66 | | Add two numbers without using any arithmetic operators | [addition_without_operators.cpp](bit_manipulation/addition_without_operators.cpp)
|
| 67 | +| Louise and Richard play a game. They have a counter set to N. Louise gets the first turn and the turns alternate thereafter. In the game, they perform the following operations. |
| 68 | + |
| 69 | +If N is not a power of 2, reduce the counter by the largest power of 2 less than N. |
| 70 | +If N is a power of 2, reduce the counter by half of N. |
| 71 | +The resultant value is the new N which is again used for subsequent operations. |
| 72 | +The game ends when the counter reduces to 1, i.e., N == 1, and the last person to make a valid move wins. |
| 73 | + |
| 74 | +Given N, your task is to find the winner of the game. |
| 75 | + |
| 76 | +If they set counter to 1, Richard wins, because its Louise' turn and she cannot make a move. |
| 77 | + |
| 78 | +Input Format |
| 79 | +The first line contains an integer T, the number of testcases. |
| 80 | +T lines follow. Each line contains N, the initial number set in the counter. |
| 81 | +|[counter_game.cpp](bit_manipulation/counter_game.cpp)| |
67 | 82 |
|
68 | 83 | ### Cracking the coding interview problems
|
69 | 84 | | Problem | Solution |
|
|
0 commit comments