0 day streak
Anonymous · shared experience20 Jul 2026 · 10 views

Nvidia: Count distinct strings with your own hash table, then make it parallel

Interview question #Nvidia Phone screen

Problem. Given an array of strings, count how many distinct strings it contains. You may not use any library containers, so you have to build the hash table yourself. The team was porting a search engine to the GPU.

Part 1. Write a working single-threaded version with a hand-rolled hash table (for example, buckets with chained lists).

Part 2. Make the table safe when many threads insert at the same time. The candidate's approach:

  • Make the per-entry counter atomic and increment it on a hit.
  • On a miss, take an exclusive lock to allocate the new entry, using shared/exclusive locking.

Afterwards the candidate felt that open addressing would have suited GPUs better than chaining.

Follow-up. How would you split about one million keys across threads? The discussion turned to coalesced (adjacent) memory access on GPUs and the similar cache effects on CPUs.

What the interviewer cared about. The interviewer was a hardware engineer. They focused on parallel correctness and memory-access patterns, not on general search knowledge.

0 comments

Comments 0

No comments yet. Ask the author something, or add what happened in your own round.