Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianminchen/6f2c5b30c9a6e9e464fb092a04aa8169 to your computer and use it in GitHub Desktop.
Save jianminchen/6f2c5b30c9a6e9e464fb092a04aa8169 to your computer and use it in GitHub Desktop.
Leetcode 84 - largest rectangle in histogram
https://leetcode.com/problems/largest-rectangle-in-histogram/description/
---
5 + 5 = 10
brute force -
2
2 -> area 2
1 _> area 5
5 -> 5-> 10
6 -> area 6
2 -> 2 2 2 2 -> 8
index = 4
-> left -> right
2 2-> area 4
<- right -> left
index = 4
2 2 2 -> 6
-> 10
time complexity index -> O(n * n)
skyline -
2 1 5 6 2 3
--------------------->
2
1 <- max = 2 (1 + 1) = 2
<____________________
}
1 2 3 4 5 6
-
-
-
-
-
-
_______________
6 5 4 3 2 1
(height, index)
1 6 4 3 2 1
- -
- -
-
- 6 4 -> 4 -> 6 8 V 6 -> 8 4
______________ 1
max 15
h , i
-------
5, 5
4, 4,
3, 1
1, 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment