FastPrepParallel String Counts with a Custom Hash Table
Problems/Parallel String Counts with a Custom Hash Table

Parallel String Counts with a Custom Hash Table

NVIDIA logoNVIDIA● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an NVIDIA phone screen for a full-time role. The report asks for counts of distinct strings without a counting package. It asks for a solution that is safe in parallel, and a talk about spreading a million keys across threads with access to nearby memory. Its hit-increment behavior points to a frequency for each key, not only how many are distinct. Here we supply custom open addressing, allowed basic concurrency tools, contiguous finite chunks, and exact frequency rows in first-occurrence order. Inputs have limits.

Our version is about 90% the same as the reported question.

Count how many times each different string appears in words. Build your own hash table and make the counting safe to run in parallel.

Return one string key:count for each distinct key, ordered by the index of its first occurrence in the input. Counts include every occurrence across all worker chunks. The number of returned rows is the distinct-key count. Return an empty array for empty input.

Use at most workers actual threads or goroutines to process nonempty input; split the input into contiguous chunks. All workers must finish before results are returned. This practice version permits ordinary arrays, string operations, core thread/goroutine and synchronization primitives. It forbids built-in maps, sets, dictionaries, counters, and external hash-table or frequency-counting packages.

The table must resolve collisions, preserve exact counts under concurrency, and return the same output regardless of the order in which workers run. Discuss the synchronization and adjacent-memory tradeoffs when scaling the same approach to a million keys.

Function

countStrings(words: String[], workers: int) → String[]

Examples

Example 1

words = ["pear","apple","pear","kiwi","apple"]workers = 3return = ["pear:2","apple:2","kiwi:1"]

Counts aggregate across worker chunks. Output follows first input occurrences, not completion order.

Example 2

words = ["a","a","a","b","a","b"]workers = 8return = ["a:4","b:2"]

At most one worker per input element is started; repeated keys from different workers merge into one row.

Example 3

words = []workers = 4return = []

There are no keys to count and no output rows.

Constraints

  • 0 <= words.length <= 5000.
  • 1 <= workers <= 8.
  • Each key has 1 to 32 lowercase ASCII letters or decimal digits, so : is never part of a key.
  • Keys are case-sensitive. The input array is read-only during counting.

More NVIDIA Phone Screen questions

  • Network Layer Execution OrderPHONE SCREEN · Seen Nov 2026
  • Paged KV Cache AccessPHONE SCREEN · Seen Nov 2026
  • Sliding Window Attention over a KV CachePHONE SCREEN · Seen Nov 2026
  • Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
  • Hash Partition OffsetsPHONE SCREEN · Seen Oct 2026
  • Filter Paginated Medical RecordsPHONE SCREEN · Seen Oct 2026
  • Least Frequently Used CachePHONE SCREEN · Seen Oct 2026
  • Simulate a Reference-Counted Smart PointerPHONE SCREEN · Seen Aug 2026
  • Streaming Top-K Frequent ElementsPHONE SCREEN · Seen Aug 2026
  • Merge Multiple Sorted StreamsPHONE SCREEN · Seen Aug 2026

Similar questions at other companies

  • Detect a Deadlock from Lock LogsHelm.ai · PHONE SCREEN
  • Rank-Based Cache with a Data SourceLinkedIn · PHONE SCREENLinkedIn interview questions
  • Bounded Service Instance RegistryRevolut · PHONE SCREENRevolut interview questions
  • Concurrent Web Crawler SimulationOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Single-Flight Chunk CacheModal · PHONE SCREEN
  • Thread-Safe Task Storage and Worker DispatchNuro · ONSITE INTERVIEWNuro interview questions
  • Blocking Keyed Cache with Waiting ReadersDatabricks · ONSITE INTERVIEWDatabricks interview questions
  • Cache an Expensive Service Across ThreadsOracle · ONSITE INTERVIEWOracle interview questions
  • Blocking Connection Pool Operation TraceGoogle · ONSITE INTERVIEWGoogle interview questions
  • Keyed Bounded Executor ScheduleMicrosoft · ONSITE INTERVIEWMicrosoft interview questions

NVIDIA interview experiences

  • NVIDIA Full-Time SWE Onsite Scheduling: 1 Experience
  • NVIDIA OA: What It Tests (2026)
  • NVIDIA DevOps, QA and Infra Intern Interviews: 12 Experiences
  • NVIDIA Ignite Internship OA Experience
  • NVIDIA Software Intern Interview Questions: 9 Experiences
  • NVIDIA Ignite SWE Intern OA Questions: 6 Experiences
All NVIDIA interview questionsSee NVIDIA hiring insights
Saved
class Solution {
    public String[] countStrings(String[] words, int workers) {
        // write your code here
    }
}
Checking account…