The Sliding Window Algorithm Explained - Max Consecutive Ones III - Leetcode 1004 - Python

preview_player
Показать описание
FAANG Coding Interviews / Data Structures and Algorithms / Leetcode
Рекомендации по теме
Комментарии
Автор

Thank you for watching the video! You can find a long-form explanation to this problem in the related video section (bottom left corner of the screen). Subscribe if you want to see these in your feed daily!

GregHogg
Автор

Dude getting jacked from bench pressing all these algorithms

dukeray
Автор

programmers after thousand leetcode questions for real

creatively
Автор

This question wasn't too tough, but I could not for the life of me figure out the logic behind contracting the window until it became valid. Your vid saved me lol

eric
Автор

We're gonna need that workout routine greg😂😂

ForexPeak
Автор

We can replace While() with simple if() by these the time complexity from O(n+n) to O(n). By replacing with if we are resisting the window from decreasing it size from the current maximum size.

prathamgolwala
Автор

Damn, he's jacked

time.sleep() build

Harmxn
Автор

Just solved this yesterday and now this video comes in my feed

Om-idqr
Автор

Master Data Structures & Algorithms For FREE at AlgoMap.io!

GregHogg
Автор

When you're bench pressing the window instead of sliding the window.

MagnumCarta
Автор

Can we use prefix sum to solve this? Compute the consecutive 1s and 0s then loop through it using sliding window

nagisa
Автор

Woah, you’re actually pretty jacked and beefy okay then

servantofthelord
Автор

i'm still a beginner at python. my version of sliding window was similar but a little different than yours. I got a time of 408ms on leetcode but it says 16% of submissions got better performance times. What can be done with either the python language or the algorithm to speed this up?

mazthespaz
Автор

O(n) i dont get it there are 2 loops, sure there is a condition for while but when it's true it would take O(n^2) right?

anas.aldadi
Автор

for some reason my idea was keep a current max, and a total max, every time the number is 1 the count gets added to the current max, and then when it’s 0 it’s reset. Then throughout the whole way, the total max is the peak of the current max.

DreadTeamLeader