xAI

Verified interview challenge

Find the k-th value in a streaming time window

Move from a static order-statistic query to one that stays correct as old stream values expire.

Unlock with Full Access

The challenge

Begin with a k-th-smallest selection problem, then extend the work to a stream of timestamped values. Queries concern only a recent window, and older values stop contributing as time advances.

The main challenge combines rank queries with changing membership. Use the supplied workload and bounded value range to choose a representation that remains correct as values arrive and expire.

What you'll practise

  • Window maintenance

    Keep only the observations eligible for the current query time.

  • Order statistics

    Answer rank queries correctly as frequencies change.

Your coding workspacePreview
Current partFurther parts unlock as you progress
solution.pyPython 3.13
# Build on your implementation

# Run checks for the current part

# Full starter code included
Current-part checks

Run your code to see results.

The complete sequence, starter code and checks are included with Full Access.