Preparing your design workspace

Loading the problem and your latest saved attempt…

Large-Input Word Frequency Analysis

Process text larger than one worker’s memory or disk and publish an exact requested top-K word-frequency result.

Problem statement

For this exercise, assume a caller submits an immutable text dataset and requests its K most frequent words with exact counts. K is an integer from one through ten, defaulting to ten; K=1 gives the most common word and K=3 gives the top three.

For this exercise, assume each maximal letter run contains at most 128 letters. Words are maximal runs of ASCII English letters, normalized to lowercase; all other bytes delimit words. Return up to K pairs ordered by descending count and then ascending word.

The caller can retry submission, inspect durable progress, and retrieve one complete result. The input can be one terabyte, ten jobs can run concurrently, and each worker has at most two GiB of memory and eight GiB of local disk.

For this exercise, assume the complete word dictionary and count state can exceed both limits of any single worker; distribute aggregation state rather than gathering the full dictionary on one machine. Target completion within one hour by scaling workers, and make accepted progress visible within five seconds.

Handle words crossing chunk boundaries and duplicate or retried worker attempts without losing or double-counting occurrences. Compare raw input in relational SQL with object storage plus SQL metadata and justify each storage boundary.

Publish a result atomically only after every required input partition has one accepted contribution and every word’s complete count is included. Retain immutable input for seven days and results for thirty days.

Exclude live streaming, edits to accepted input, multilingual segmentation, approximate counting, search and historical analytics.

What to build

  1. Submit an immutable dataset and requested K under a stable job identity; recover the same job on an exact retry and reject conflicting reuse.
  2. Inspect durable queued, running, failed, or completed progress and retry recoverable work without changing the logical input.
  3. Compute exact normalized word frequencies across the entire input and return the deterministic requested top K, default ten, only after complete aggregation.

At scale

  • For this exercise, assume up to one terabyte of text per dataset and ten concurrent jobs.
  • For this exercise, each worker has at most two GiB of memory and eight GiB of local disk; the complete dictionary/count state can exceed both limits of any one worker.
  • For this exercise, target one-hour completion using scalable workers and progress updates visible within five seconds.
  • For this exercise, retain immutable input for seven days and completed results for thirty days; worker/coordinator restarts must not corrupt an accepted result.