- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
LeetCode 84 | Largest Rectangle in Histogram (Part 1) #leetcode #dsa #codingwithyash
This one’s a hard problem and requires a lot of patience and focus.
Problem statement:
We are given an array of heights, and we need to find the area of the largest rectangle that can be formed inside the histogram.
In this part, we’re solving it with a brute-force approach:
✅ Approach:
For every bar we expand to the left and right as long as the bars are greater than or equal to the current one.
Once we find boundaries on both sides, we calculate the width.
Then simply multiply width × current height to get the area.
Keep track of the maximum area and at the end we will return the maxArea.
Time Complexity: O(n²)
This method works, but it’s not optimal and may fail for large inputs due to TLE.
In Part 2, we’ll cover the stack-based approach that solves this in O(n) time and it’s what most interviewers expect.
If you understood the approach please do subscribe to my channel for more such DSA concepts.
---Tags---
#leetcode #leetcodechallenge #codingwithyash #datastructures #interviewquestions #placementprep #dsa #dsaforbeginners #javaprogramming
Видео LeetCode 84 | Largest Rectangle in Histogram (Part 1) #leetcode #dsa #codingwithyash канала CodingWithYash
Problem statement:
We are given an array of heights, and we need to find the area of the largest rectangle that can be formed inside the histogram.
In this part, we’re solving it with a brute-force approach:
✅ Approach:
For every bar we expand to the left and right as long as the bars are greater than or equal to the current one.
Once we find boundaries on both sides, we calculate the width.
Then simply multiply width × current height to get the area.
Keep track of the maximum area and at the end we will return the maxArea.
Time Complexity: O(n²)
This method works, but it’s not optimal and may fail for large inputs due to TLE.
In Part 2, we’ll cover the stack-based approach that solves this in O(n) time and it’s what most interviewers expect.
If you understood the approach please do subscribe to my channel for more such DSA concepts.
---Tags---
#leetcode #leetcodechallenge #codingwithyash #datastructures #interviewquestions #placementprep #dsa #dsaforbeginners #javaprogramming
Видео LeetCode 84 | Largest Rectangle in Histogram (Part 1) #leetcode #dsa #codingwithyash канала CodingWithYash
coding with yash codingwithyash dsa in java full course leetcode solutions leetcode problems data structures and algorithms in java dsa for beginners #shorts leetcode leetcode tutorial data structures playlist faang interview preparation leetcode questions largest rectangle in histogram leetcode 84 largest rectangle in histogram leetcode largest rectangle in histogram java rectangle in histogram leetcode java leetcode largest rectangle in histogram
Комментарии отсутствуют
Информация о видео
2 ноября 2025 г. 19:47:11
00:03:00
Другие видео канала





















