xAI

Verified interview challenge

Sort integers with bounded worker threads

Distribute sorting work across threads and combine the pieces into one correctly ordered result.

Unlock with Full Access

The challenge

Sort a large integer list using a bounded number of worker threads, preserving duplicates and leaving the input unchanged. Each worker can sort a portion, but the final result must be ordered across all portions.

Implement the division of work and the combination of its results, then explain the practical limits of the approach. The exercise distinguishes correct concurrent execution from an assumption that adding threads always makes a workload faster.

What you'll practise

  • Bounded concurrency

    Partition work while respecting the worker limit and small-input behaviour.

  • Result merging

    Combine independently sorted chunks without losing values or changing the input.

Your coding workspacePreview
solution.pyPython 3.13
# Your implementation goes here

# Run examples and inspect results

# Full starter code included
Test cases

Run your code to see results.

Full instructions, starter code and test cases included with Full Access.