Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Brick Wall

A wall is built from rows of bricks of equal height but different widths; every row has the same total width. A vertical line drawn from top to bottom crosses a brick unless it passes along a gap between bricks (the wall's two edges do not count). Print the minimum number of bricks the line must cross.

Constraints

1 <= r <= 10^4 Total number of bricks <= 2 * 10^4

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.