Which optimized bit manipulation pattern solves this lesson cleanly?
Practice this question from Number of 1 Bits - Brian Kernighan Pattern Practice Quiz, with options and an explanation.
Question
Which optimized bit manipulation pattern solves this lesson cleanly?
Option A — Correct answer
Brian Kernighan loop using n & (n - 1).
Option B
Nested loops without bit identities
Option C
Sliding window only
Option D
Min-heap of size k only
Explanation
Brian Kernighan loop using n & (n - 1).