← All problemsSign in

1840. Maximum Building Height

LeetCodeArrayMathSortingOpen on judge ↗

You want to build n new buildings in a city. The new buildings will be built in a line and are labeled from 1 to n. However, there are city restrictions on the heights of the new buildings: - The height of each building must be a non-negative integer. - The height of the first building must be 0. - The height difference between any two adjacent buildings cannot exceed 1. Additionally, there a

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start