# 20.06.2026 [1840. Maximum Building Height]

20.06.2026 [1840. Maximum Building Height](https://leetcode.com/problems/maximum...) hard [substack](https://open.substack.com/pub/dmitrii...) #### Join me on Telegram https://t.me/leetcode_daily_unstoppab... #### Problem TLDR Max growing height with restrictions #### Intuition ```j // 123456789 10 11 // 123456543 21 // 1 6 3 // 1 2 3 4 5 6 7 8 9 10 // 0 5 3 4 3 // // some restriction in the middle can backtrack // // 30 minutes, hints: two passes // 48 minute: my formula is wrong // 56 minute: give up ``` adjust restrictions with forward anb backward passes for each restriction interval the max height = (L+R+d)/2, solve 2D geometry #### Approach on backward pass we already can calculte the max we can use 'previous' height and solve in O(1) memory, or use helper collection with 0 and n-th positions #### Complexity Time complexity: O(nlogn) Space complexity: O(n|1) #### Code https://dmitrysamoylenko.com/leetcode/