InterviewLegend

Bit Manipulation & Masks

Alex Chen20 min readUpdated 139 real interview reports

Bit manipulation comes up at NVIDIA more often than at most software companies, and most of it lands in the online assessment. The problems are short. One asks whether two memory addresses sit on the same 4 KB page, another has you reverse a range of bit positions in a 32-bit value in constant time, and a third gives you a running XOR and wants back the array that produced it. None of them runs past a dozen lines of code. What decides them is the word width, the off-by-one at a page edge and whether you can explain why the mask works.

These problems come from everyday driver and CUDA work, where code maps memory in fixed-size pages and rewrites one field of a hardware register without touching its neighbours. Interviewers who write that code read a clean mask as a sign you've done the same, and they notice a mask built in the wrong width quickly. Some systems teams run the assessment in C only. Practice these in C or C++ as well as in Python.

The NVIDIA angle
Say the width before you write the mask. JavaScript's bitwise operators convert to 32 bits first, so a 47-bit address lands on the wrong page. In C, ~0xFFFu is a 32-bit unsigned int, and widening it to 64 bits zero-extends away every page-number bit above bit 31. A Java int keeps its sign in bit 31, so >> drags copies of it down unless you write >>>. So name the type that holds the value, build the mask in that type, and say so as you type it. If you skip that, an interviewer who works on driver code may ask what ~ does to a 64-bit address.

NVIDIAPremium lesson · Coding round

The 3 NVIDIA problems are below.

  1. A Premium questionCoding · Easy · Signature problem
  2. A Premium questionCoding · Medium
  3. A Premium questionCoding · Medium

Each with hints, the follow-up and a tested solution.

Get the NVIDIA questions

$49 a year · all 100 companies · cancel anytime

From 139 NVIDIA reports, forum threads behind logins and write-ups in Chinese.

Had your NVIDIA interview?Tell us what they asked. Reviewed before it goes in, never with your name.
NVIDIA interview guide

Know what NVIDIA asks before you walk in.

23 coding · 2 system design · 22 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.