Logo

Coding preview

Build a Histogram

What this preview is

About this preview

Build a Histogram is a cooked quant coding problem on language knowledge in Cpp / Python, asked at Quant.

Unlock full access to getcracked

Join to unlock this problem, detailed solutions, and our complete library of quant finance interview prep.

Building a flexible histogram for latency metrics in distributed systems

This is a medium-difficulty coding problem that tests your ability to design and implement a data structure for aggregating performance telemetry in a production environment. It's representative of the kind of infrastructure work junior quantitative developers do at trading firms: taking raw observations (network latencies) and organizing them into buckets for statistical analysis.

The problem asks you to build a histogram class that accepts a configurable number of buckets, each with a fixed power-of-2 width. The key challenge is handling the boundary cases correctly—each bucket has a defined lower and upper bound except the final bucket, which is unbounded and captures all values above a threshold. You'll need to decide how to map incoming latency values to the correct bucket efficiently and how to store and expose the counts.

  • Bucket boundaries and range mapping
  • Power-of-2 sizing and bit operations
  • Handling unbounded (overflow) buckets
  • Correctness under concurrent updates (if applicable to your language)

Solutions in C++ and Python differ mainly in memory layout and thread-safety considerations. Both require careful indexing to avoid off-by-one errors and clear logic for determining which bucket a given value belongs to.