No video

Max Consecutive Ones III - Leetcode 1004 - Sliding Window (Python)

  Рет қаралды 4,498

Greg Hogg

Greg Hogg

3 ай бұрын

Master Data Structures & Algorithms for FREE at AlgoMap.io/
Code solutions in Python, Java, C++ and JS for this can be found at my GitHub repo here: github.com/gahogg/Leetcode-So...
Complete DSA Pathway Zero to Hero: • Data Structures & Algo...
Please check my playlists for free DSA problem solutions:
• Fundamental DSA Theory
• Array & String Questions
• 2 Pointers Questions
• Sliding Window Questions
• Binary Search Questions
• Stack Questions
• Linked List Questions
• Tree Questions
• Heap Questions
• Recursive Backtracking...
• Graph Questions
• Dynamic Programming (D...
My Data Science & ML KZfaq Playlist: • Greg's Path to Become ...
Learn Python and Data Science FASTER at mlnow.ai :)
Support the content: / @greghogg
Follow me on Instagram: / greghogg5
Connect with me on LinkedIn: / greghogg
Follow me on TikTok: / greghogg5
Coursera Plus: imp.i384100.net/P0E3J6
My Favorite Courses:
Data Structures & Algorithms:
- UCalifornia San Diego DSA: imp.i384100.net/LP31oV
- Stanford Algorithms: imp.i384100.net/vNBoxd
- Python Data Structures: imp.i384100.net/NkZn47
- Meta Coding Interview Prep: imp.i384100.net/Y96rBJ
Python:
- UMichigan Python for Everybody: imp.i384100.net/QOLM73
- Python Mastery from MLNOW.ai: mlnow.ai/course-material/python/
- Google IT Automation w/ Python: imp.i384100.net/5g6Xyj
Web Dev / Full Stack:
- Meta Front-End Developer: imp.i384100.net/q4Jemy
- IBM Full Stack Developer: imp.i384100.net/Gj9dMn
- Meta Back-End Developer: imp.i384100.net/xkW0r5
- John Hopkins HTML, CSS & JS: imp.i384100.net/QyoRAA
- IBM DevOps: imp.i384100.net/kjd2r0
Cloud Development:
- AWS Fundamentals: imp.i384100.net/anqBjZ
- GCP Cloud Engineer: imp.i384100.net/g1jvqB
- Microsoft Azure Fundamentals: imp.i384100.net/EKm5O4
Game Development:
- Michigan State Unity Development: imp.i384100.net/6eOBnr
- UColorado C++ for Unreal Engine: www.coursera.org/specializati...
SQL & Data Science:
- SQL by MLNOW.ai: mlnow.ai/course-material/sql/
- Python for Data Science by MLNOW.ai: mlnow.ai/course-material/data...
- Google Data Analytics: imp.i384100.net/1rkWAR
- IBM Data Science: imp.i384100.net/P0ZRL6
- IBM Data Engineer: imp.i384100.net/4PbZyZ
Machine Learning & AI:
- ML Mastery at MLNOW.ai: mlnow.ai/course-material/ml/
- ML w/ Andrew Ng: www.coursera.org/specializati...
- Deep Learning w/ Andrew Ng: imp.i384100.net/a1kjJj

Пікірлер: 27
@GregHogg
@GregHogg 15 күн бұрын
Master Data Structures & Algorithms For FREE at AlgoMap.io!
@user-eq9zo5vj7c
@user-eq9zo5vj7c 2 ай бұрын
The clearest explanation and visualization I've ever seen on sliding windows .....keep them coming.
@GregHogg
@GregHogg 2 ай бұрын
Oh I'm really glad to hear that 😊
@bhagyashreepani4059
@bhagyashreepani4059 13 күн бұрын
I was searching for a conscised list to practice DSA questions covering all major concepts, and here it is! Thanks alot ! @GregHogg, YOu are doing awsome job and helping millions ! keep it up! I would need more questions from easy to hard level on bit manipulation i feel less confident on this one
@sangyetenphel
@sangyetenphel 13 сағат бұрын
Thank you very much for the explanantion. I was stuck on this problem but you explained it in a very simple and straightforward manner.
@user-hu9nu8xu5g
@user-hu9nu8xu5g 11 күн бұрын
Respect must be earned not given, you have my huge respect gregg hog, you are nothing except truth love and real life not explain anything garbage
@GregHogg
@GregHogg 11 күн бұрын
Haha thanks so much 😊
@user-hu9nu8xu5g
@user-hu9nu8xu5g 9 күн бұрын
You're never truly happy if you deceiving people, I don't care how many money you make, if you're bad person or you trick people, lie people, or do bad things to people, you're will never feel happy, truly happy in your heart, we're intrinsically borned to do the right things to people and you have proved that, I have huge respect for you Greg Hogg, when you have that, you understand that, that's more important than anything else, mind is all and today the truth is the world is getting harder and harder, people's mind is fucked and controlled by those garbage system, you have huge respect from me Greg Hogg, I wish you all the best things in your life with your dreams, with love & truth, who the fuck doesn't gonna to love you? You're so fucking amazing, thank you so much bro I fucking love you and I think people are fucking love you too, so much respect for you bro
@GregHogg
@GregHogg 9 күн бұрын
Awe that's so sweet thank you 🥰
@xinweili5644
@xinweili5644 19 күн бұрын
Very well explained and the example given is helpful. Thanks for the video.
@hrushirajg9991
@hrushirajg9991 2 күн бұрын
Thank you so much for explaining it so clean !
@christianjt7018
@christianjt7018 4 күн бұрын
Very clear explanation, thanks!
@Lil.Mushroom
@Lil.Mushroom 2 ай бұрын
I just came from the reels and i could not be happier
@GregHogg
@GregHogg 2 ай бұрын
Oh glad to hear this helped! :)
@niranjanbhat3949
@niranjanbhat3949 3 ай бұрын
Great video buddy 👏🏻! Would love more such . Can u also cover some math and bit manipulation questions?
@GregHogg
@GregHogg 3 ай бұрын
Will do, and thanks so much 😁
@ridheesh4765
@ridheesh4765 26 күн бұрын
You could keep track of the the first zero in the window, that way you wont have to loop to shrink the window when needed
@bhuvanachandrag5589
@bhuvanachandrag5589 Ай бұрын
Hi Greg, Thanks for the amazing video and explanation. I have a quick question on the code implementation. On line 12, I do not think the while loop runs more than once. Because we are flipping one zero at a time with the help of the condtion above it (Line 9). Example, if we have flipped 3 zeroes and k = 2 and our intention is to get back one zero (num_zeroes -= 1), we run through the while loop to decrement. But here, after the first iteration of while loop, the condition evaluates to false (2 > 2). This is because we incremented num_zeroes from 2 to 3 (We are flipping one zero at a time). So, my question is to know the intention of selecting a while loop on Line 12. Since, while loop doesn't work for more than one time, I replaced it with a simple if condition. So, Line 12 will become, if (num_zeroes > k): num_zeroes -= 1. The code will still work for all the cases. Here's my code: class Solution: def longestOnes(self, nums: List[int], k: int) -> int: left = 0 max_num = 0 num_of_zeroes = 0 for index, num in enumerate(nums): if num == 0: num_of_zeroes += 1 if num_of_zeroes > k: if nums[left] == 0: num_of_zeroes -= 1 left += 1 max_num = max(max_num, index - left + 1) return max_num
@quchengpeng6905
@quchengpeng6905 2 ай бұрын
Excellent answer 🎉🎉🎉🎉
@GregHogg
@GregHogg 2 ай бұрын
Very happy to hear it :)
@BasicToAdvance_101
@BasicToAdvance_101 3 ай бұрын
Hi Greg, Nice Explanation.What drawing tool do you use ?
@GregHogg
@GregHogg 3 ай бұрын
Thank you! I use miro :)
@BasicToAdvance_101
@BasicToAdvance_101 3 ай бұрын
@@GregHogg Thanks, Keep up with good work.
@S4ntia60
@S4ntia60 3 ай бұрын
IMHO, sliding window algos are very elegant
@GregHogg
@GregHogg 3 ай бұрын
They really are 😊
@onurucar1112
@onurucar1112 3 ай бұрын
Amazing content as usual! I enjoy watching your solutions after I try implementing by myself
@GregHogg
@GregHogg 3 ай бұрын
That's awesome, that's a really good way to do it 🙂🙂
Coin Change - Leetcode 322 - Dynamic Programming (Python)
15:27
Greg Hogg
Рет қаралды 3,3 М.
Fast and Furious: New Zealand 🚗
00:29
How Ridiculous
Рет қаралды 46 МЛН
Они так быстро убрались!
01:00
Аришнев
Рет қаралды 2,4 МЛН
R vs Python
7:07
IBM Technology
Рет қаралды 315 М.
Subsets - Leetcode 78 - Recursive Backtracking (Python)
11:51
Greg Hogg
Рет қаралды 3,9 М.
Magic Squares In Grid - Leetcode 840 - Python
21:12
NeetCodeIO
Рет қаралды 1,6 М.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 161 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 411 М.
Diameter of Binary Tree - Leetcode 543 - Trees (Python)
11:16
Greg Hogg
Рет қаралды 3,1 М.
Sliding Window Technique - Algorithmic Mental Models
36:45
Ryan Schachte
Рет қаралды 338 М.
Find if Path Exists in Graph - Leetcode 1971 - Graphs (Python)
12:20