Linked Lists & Pointers
Pointer problems make up an unusually large share of NVIDIA's coding questions, and plain linked-list reversal sits near the top. The interviewers who ask them write drivers, kernels and runtimes in C++. In that code a list is a chain of heap nodes somebody has to free, and a lost next pointer leaks everything behind it. So the follow-ups go where a library list would hide the work, like who owns each node and what your code does when the node to change is the head.
Reversal ties the three problems together. One flips a list one segment of links at a time and stitches each segment back in. Another flips a character buffer twice, once whole and once per word, and the no-STL rule some C and C++ interviews set means you do it inside the buffer you were handed. The third, removing a node counted from the end, reverses nothing but uses the same discipline, a dummy node in front of the head and two pointers held a fixed gap apart.
ListNode. So build your own node type and a test list before the solution. Write the struct, a builder that turns an array into a list and a printer that turns it back, then run your solution on a list you made. A relinking bug then shows up on your own screen before the interviewer finds it.
On a C++ team, finish by saying who deletes the unlinked nodes and when. If you leave that out, the code looks like it has never run under a leak checker.NVIDIAPremium lesson · Coding round
The 3 NVIDIA problems are below.
- A Premium questionCoding · Medium · Frequently asked
- A Premium questionCoding · Hard
- A Premium questionCoding · Easy
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.
NVIDIA interview guideKnow what NVIDIA asks before you walk in.
23 coding · 2 system design · 22 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.