← Nvidia questions
CodingReported in a candidate post, Sep 2023

Reverse bits in a range l to r of an integer in O(1)

Filed under Nvidia

Given a 32-bit integer x and bit positions l and r (0 is the least significant bit, l <= r), reverse the order of the bits from position l to r inclusive and return the new integer, in constant time.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Nvidia questions

Collected from public candidate posts and coding forums. Updated Nov 2026.