Question bank › Bit Manipulation
Dsa Bit Manipulation Medium

Toggle Bits from a Range

You are given an integer N and two indices L and R. Write a program that toggles the bits of N from index L to index R (inclusive). Indices are 0-based and counted from the right. Print the resulting integer after toggling the bits. For example: Input: 29 1 3 Output: 24 Explanation: The binary representation of 29 is 11101. Toggling bits from index 1 to 3 results in 11000 (24 in decimal).

Key concepts

bit_manipulationrange_toggle

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.