RUVIDEO
Поделитесь видео 🙏

NeetCode150 - SLIDING WINDOW MAXIMUM | Hard Level Question | LEETCODE | Sliding Window | DSA Python смотреть онлайн

In this video, we'll be solving the 17th question "Sliding Window Maximum" from Sliding Window topic in NeetCode150 sheet. This is a hard level question that has been tried to explain in this video.

Question Link: https://leetcode.com/problems/sliding-window-maximum/

Explaining this question was a lil difficult for me. So for a better understanding I am writing here in the description.
There are three things we are focusing on.
1. Removing elements smaller than the current element and adding the current element to the deque
2. Removing elements outside of current window
3. Adding the maximum element to the result

Explanation:

2. Removing elements outside of current window
The condition "q and q[0] less than i - k + 1" is used to check if the index of the element at the front of the deque q[0] is still within the current sliding window.
'q' is the deque that stores the indices of the elements in the current sliding window.
When we move the window to the right by one position, the leftmost element of the current window is no longer within the window, so we need to remove it from the deque.
The expression i - k + 1 is used to calculate the index of the leftmost element of the current sliding window.

3. Adding the maximum element to the result
The condition "if i greater than or equal to k - 1" is used to check if we have a complete sliding window.
Here, i is the index of the rightmost element of the current sliding window, and k is the size of the sliding window. So, when i is greater than or equal to k - 1, it means that we have a complete sliding window of size k.
At this point, we can append the maximum element of the current sliding window to the result list res. The maximum element is always at the front of the deque, so we append nums[q[0]] to res.


Time Stamps:
00:00 Introduction
00:13 Understanding the Question and Example
01:39 Brute Force Approach
03:40 Better Approach using Deque
07:30 Coding & Explanation

I am also a learner like you and exploring the coding world! Trying to do DSA in Python so feel free to suggest me some better ways to explain or code by leaving your comments below.

Check out the codes at https://github.com/niralverma/neetcode150

Connect with me on -
LinkedIn: https://www.linkedin.com/in/niral-verma/
Instagram: https://www.instagram.com/niral.verma/
Email: [email protected]

If you're a beginner looking to start coding, then this is the video for you!

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «NeetCode150 - SLIDING WINDOW MAXIMUM | Hard Level Question | LEETCODE | Sliding Window | DSA Python» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.