Master Data Structures & Algorithms For FREE at AlgoMap.io!
@dantemix Жыл бұрын
Please never stop this series.
@gabedailey3249 Жыл бұрын
Always have trouble visualizing sliding window keep it up dawg
@mfaaniАй бұрын
This is a great video. It just gives you the main idea needed. And that’s really what we all need for learning about how to code these.
@sevenscapes10 ай бұрын
Great explanation👏👏
@va3802 Жыл бұрын
These are helping me with LeetCode while in my freshmen year.🚀
@vm16625 ай бұрын
These shorts are amazing. Thank you!
@davea1367 ай бұрын
Excellent explanation. Why am I watching this on a Saturday night?
@masteradvisor5944 ай бұрын
Please never stop this
@_HariHaranR9 ай бұрын
Good approach.
@GregHogg9 ай бұрын
Glad you think so!
@LukeSorvik10 ай бұрын
nice explanation
@Malayalam_learner3 ай бұрын
Great video
@mohitc428926 күн бұрын
dude i used to watch you on ig when you abrey had followrrs wow
@smash492911 ай бұрын
How simple you want to make it? Greg: YES
@GregHogg7 ай бұрын
Can't believe I missed this... Thank you buddy :)
@boring-person-rishabh6 күн бұрын
In java if they are English alphabets use can use an array with a being 0 index b being 1 index and so on
@MrEo89 Жыл бұрын
Great series, just read up on how to do the visualizing and you will have thousands of followers in no time. Quality > quantity, every time. Edit: also, don’t zoom in as much, you’re constantly clipping the sides of the code snippets off. Set a text width of 60 or zoom out to like 50%. Most phones nowadays have great resolution so if anything we can pinch to zoom at our preference.
@prasad4you57s2 Жыл бұрын
You made it clear and cool
@kur0sh1 Жыл бұрын
if you're using a string you could just use an array of the size if the number of alphabets. Then you could just index the array with something like ['z' - curr_char ]. You still get the access in constant time without the overhead of a hashing function and all you trade for it is a few extra bytes for the array. I really think people should try to do these problems without using built-in data structures and instead should try to implement their own as that helps you so much in getting a better understanding of these algorithms and programming im general.
@d.g.m.047 ай бұрын
using maps and sets and what not in these is such an overkill for me its crazy, i'd call it lazy programming lmao
@alwinthomas22885 ай бұрын
Hi should i use cpp over python due to TLE issue??
@methodsystem42514 ай бұрын
I have a question if I try to solve the same problem using other techniques Leetcode says Error even though my code is correct. Does Leetcode expect us to solve the problem using only one approach?
@vetiarvindАй бұрын
what's the difference between sliding window vs 2 pointer?
@darcash17386 ай бұрын
As I see it there are two variations to the sliding window, based on what I’ve seen so far. Set subset length(in which you move the right pointer until you get to that length, at which point you can increment both left and right to maintain that length) or undetermined subset length like this, which is based on some condition before you set left = right to start a new subset altogether. Is this correct?
@GregHogg6 ай бұрын
Yes you're completely right
@darcash17386 ай бұрын
@@GregHogg awesome, thanks!
@anshusarkar71136 ай бұрын
What is the difference between a set and a hash set ?
@doodledude19767 ай бұрын
So seeing as how s[r] will always be in the set, can i clear the set, add s[r] to it, and say l = r? I’m trying to get rid of the while loop
@GregHogg7 ай бұрын
No, that won't let it slide properly. It needs to expand and contract as needed.
@lil_jeke4 ай бұрын
What’s the TC O(n^2) ?
@giancarlokuosmanen97232 ай бұрын
O(n)
@beardbarbe28243 ай бұрын
Great video just dont get why you are using a set here. Since you checking if the element is in the set at each iteration… 🤔
@prasad4you57s2 Жыл бұрын
Please add time and space complexity for all the problems
@GregHogg Жыл бұрын
O(n) for both :)
@KJ-wf1xz10 ай бұрын
Why it’s On time complexity when you need to search through a set at least once moving to the right.
@KJ-wf1xz10 ай бұрын
If you have a string with no repeating characters, the length of set grow from 1 to n-1. Does it make this problem On^2 time complexity?
@rdubb777 ай бұрын
@@KJ-wf1xz array is only traversed once. O(n)
@HR-pz7ts Жыл бұрын
So that's where I was wrong. I was using a hashmap instead. And clearing the map when there was a repeat. I never thought of learning this algorithm as I wanted to come up with it naturally but then again I still have hadhset to learn. So I'm still learning.
@overbored1337 Жыл бұрын
Actually a hashmap is better, or even an array. If you make it store an unique incrementing uint32 is you would only need to erase it on every 4 billion run.
@deleteduser8822 Жыл бұрын
hmm so is this another expression for two pointers ?
@GregHogg Жыл бұрын
It's definitely an example of using two pointers
@onlyAI..2 ай бұрын
Isn't it O(n2) ??
@SanSu_Web37 ай бұрын
Why didn't you use a map instead?
@GregHogg7 ай бұрын
You could. No need though nothing to map to
@riteshkumar-ve3hs7 ай бұрын
You are only finding unique characters this way, not the longest unique substring. Your code will return max_len = 4 when input is pwwkew but actual answer is 3.
@d.g.m.047 ай бұрын
damn you are right. Instead he could have just ran the inner while loop until the character that just occurred on the right is skipped on the left and that guarantees there's only 1 left.
@healthplanetary3 ай бұрын
Wanted in java
@rohitwaghmode21235 ай бұрын
giving me TLE on gfg 😭 1038/1071
@ajaymishra1511Ай бұрын
now optimize it
@misfries61877 ай бұрын
bro this is n^2 u can do better
@GregHogg7 ай бұрын
Actually, it's O(n)! The nested for loop doesn't make it n^2