Largest Rectangle in a Histogram

Talk it through with a coach who asks guiding questions and gives hints until you reach the answer. Pass to mark the challenge as completed.

The problem

  • hard
  • Pro

Given the heights of bars in a histogram, each one unit wide, find the area of the largest rectangle that fits entirely within the bars. Explain how to do it in linear time.

Talk this problem through with an AI coach

This is a Pro challenge. Sign in with Google, then upgrade to start a voice session.

Start free →