@CodingWithJohn

Thanks to Mailgun for sponsoring this video! Head to https://mailgun.com/john to try Mailgun free today.
Looking forward to seeing how you guys make this solution even better!

@playtopgames3261

Best java chanel on YouTube

@nahomg6945

You genuinely have one of the best programming explanation videos on this site, honestly. Funny, I was discussing learning about the Sliding Window algorithm to practice Leetcode questions with a friend yesterday, and lo and behold you've uploaded a great explanation literally 24hrs later, legendary! Could you please upload more Leetcode explanation questions? If not on Youtube, perhaps a course?

@jayshreebargohil

I had just solved this problem and found this video. You explained each solution and your approach in the best way. Your way to explaining make things crystal clear John !!

@vijal-patel

please keep doing these, your explanations are so much more in depth than other youtube channels

@thomas_m3092

John, you are a wizard. Everythings looks so logical and simple. Please make more videos like this.

@yashshah2775

The way you walked through the solution was like i have never seen anywhere. Most youtubers just jump to the optimal solution. please do more of these! I went to your channel hoping to find a video series of Blind 75. but wasn't there. Please do a playlist of Blind 75. I bet people would love to see those.

@tund_101_hd9

This is probably one of the best tutorials out there and i think YouTube is with me in this.❤️ I could you not, even though I have watched it already it is every time the first video in my recommended 😂
Guess I'll watch it twice. Keep up the good work!

@tiagocarvalho4119

You have to be careful when using a MAP to lookup something because, even though its O(1) in time complexity, there is a lot of overhead. Let's say that the constant time for a lookup in a MAP is always 500 nanoseconds, if the indexOf (that has a time complexity of O(n)) takes only 300 nanoseconds because it finds the answer in the first few characters, then the indexOf will perform better. This obviously can be measured and we can come up with some threshold that tells us what algorithm to use in each situation. My guess is that in the English language indexOf will always perform better because we are dealing with words that are small in size (there is always the repeating space character).

@MTB_Bay_Area

For the brute force solution. I suggest checking if the max need to be updated in the "if contains part" that makes sure that we only do it right before we break. It is one time per substring. We fount a substring, now, let's check if it is better than the other we had so far. Second, I will suggest using HashSet instead of StringBuilder. HashSet has contains method and it is faster.

@claytonalmeida6046

Would love to watch a complete java dsa course from you

@whiz-code

You are really a coding geek. Even the concepts known, still visit them and keep something. Your explanations are far reaching. Thank you.

@minakianrad812

An excellent in-depth explanation of two approaches to solving this problem. Thank you very much, John.

@Michaelpschreib

I appreciate that you go into the brute force solution and also the more clever solution. Thanks for these!!

@SimanAndGarfunkel

I love the final thoughts on the differences of performance between the 2 last algorithms, answered all the questions I had to myself. Thnak you!

@foratzoabi1311

Hey John!  First of all thanks for the amazing video!

Short answer for why indexOf is faster in this case:

It is simply because in this case it has an O(1) runtime, how? here is how:

Before you slide your right pointer to the right you have already made sure that this substring has different characters, which in the worst case will be 24 characters long. Since you know it will never be longer than 24 characters, or 34 if numbers are included in the string, then it is constant time, because no matter how big your string will be, it will be in the worst case that maximum substring :D so it is related to the valid substring and not to the input! :D

And since the map indeed has access and write time of O(1) it still has an overhead for hash calculation and storing and etc... which take more operations / time than indexOf in that case, but since none of them is related to n, the one with the shorter/faster operations wins :D

I hope that was helpful!

@rushio8673

Great job, please keep posting the leetcode solution videos in structural manner(for eg top 50 that includes most practices/datastructures) , this helps a lot in preparing for interviews.

@yasasmaddumage

I love this series. Thank you...

@elizabeth00653

John I love your Java explanations, can you please add more leetcode to your channel or bootcamp? I would love to see more Java leetcode solution guides properly explained

@rahulg1715

At 35:00 we should use indexOfFirstAppearenceInsubstring<right in place of !=right because we are getting index from whole string with start index as left so that character may be repeat in right of current character and should not be consider as it's not part of current substring.