Data Structures & AlgorithmsModerateTCS NQT · CAT
Problem: What is the value of the lowest set bit of 96 (the largest power of 2 dividing 96)?
- A. 64
- B. 3
- C. 32
- D. 5
Correct answer: C. 32
96 = 1100000₂, and 96 & −96 keeps only the lowest 1, which is 32. n & (n − 1) clears that bit and leaves 64, 3 is the odd part, and 5 is the bit's index, not its value.
More Coding Interview Problems questions
- Problem: For the numbers 1, 2, 3, 4, 5, how many unordered pairs (i, j) with i < j have i XOR j strictly less than 4?
- Problem: What is the sum of the proper divisors of 220 (divisors less than 220)?
- Problem: What is the smallest positive integer n such that 1 + 2 + … + n is divisible by 10?
- Problem: Compute 7^100 mod 13.
- Problem: Using US coin denominations 1, 5, 10, 25, what is the minimum number of coins needed to make 63 (greedy works for these…
- Problem: Count the walks of length 3 on the path graph P4 (vertices 1–4, edges 1-2, 2-3, 3-4) that start and end at the same vertex. Walks…