Skip to content

Commit c538b24

Browse files
committed
Day 54 CTCI problems
1 parent 76fe09c commit c538b24

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

README.md

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,7 @@ Include contains single header implementation of data structures and some algori
6464
| How many bit flip operation would require to convert number A to B. | [countNumberOfBitFlips.cpp](bit_manipulation/countNumberOfBitFlips.cpp)|
6565
| 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)|
6666
| 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+
| 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: <ul><li>If N is not a power of 2, reduce the counter by the largest power of 2 less than N.</li></ul><ul><li>If N is a power of 2, reduce the counter by half of N.</li></ul> The resultant value is the new N which is again used for subsequent operations.The game ends when the counter reduces to 1, i.e., N == 1, and the last person to make a valid move wins. <ul><li> Given N, your task is to find the winner of the game. If they set counter to 1, Richard wins, because its Louise' turn and she cannot make a move.</li></ul><ul><li>Input Format : -The first line contains an integer T, the number of testcases. T lines follow. Each line contains N, the initial number set in the counter.|[counter_game.cpp](bit_manipulation/counter_game.cpp)|
8268

8369
### Cracking the coding interview problems
8470
| Problem | Solution |

0 commit comments

Comments
 (0)