Python Programming Practice: LeetCode #3 -- Longest Substring Without Repeating Characters
Фильм және анимация
In this episode of Python Programming Practice, we tackle LeetCode #3 -- Longest Substring Without Repeating Characters.
Link to the problem here:
leetcode.com/problems/longest...
This is a medium difficulty problem, so getting a passing solution will generally require submitting code that performs better than a naive brute force solution.
If you don't know Python, you can learn the basics of Python for data analysis using this guide I created on Kaggle (DataDaft video series forthcoming): www.kaggle.com/hamelg/python-...
Python Programming Practice is a series focused on teaching practical coding skills by solving exercises on popular coding websites. Note that the solutions seen here may not be the most efficient possible.
I am not going to provide the full code in the video description for this series, since copy and pasting solutions is not in the spirit of doing coding exercises. It is intended that the video will help you think about problems, approaches and how to structure solutions so that you are able to code up a working solution yourself. .
⭐ Kite is a free AI-powered coding assistant that integrates with popular editors and IDEs to give you smart code completions and docs while you’re typing. It is a cool application of machine learning that can also help you code faster! Check it out here: www.kite.com/get-kite/?...
Пікірлер: 49
Best Explanation ever you are the indian youtuber of leetcode
The legit GOAT. Explanations always soo good. Thank you!
Amazing explanation! The way you take your time to visualize the concepts and reinforce ideas even when you're already coding is so helpful. Wish you would do more leetcode in Python, as there is a great need for videos that explain the concepts in depth as you do.
amazing job. please continue to these practices, I'm learning a lot
Please make more awesome videos like this, DataDaft!
I find it extremely helpful watching you talk through the problem solving. It is good to practice talking through problems imitating how you join the dots for myself, so I can at least pretend I understand whats going on :D
Are you kidding, 0 comments, only 7 upvotes? LIked and subscribed and hoping to see more.
When I saw the program faster than 99.37% and memory usage less than 100%, I immediately hit the subscribe button.
Thank you sir. Just starting out with leetcode after a few MOOCs, and this is very helpful. Appreciate it!
@DataDaft
3 жыл бұрын
Glad to be of service. =)
Nice! What you mentioned about measuring the run time of a solution before writing code is really valuable advice!
loved it, very clear explanation! thank you!
Its very helpful, please keep making more. Great Work
Clear solution, commenting to support this type of content
Thank you. Your explanation is awesome!
please upload more leetcode problem solutions. Loved your teaching skills! Best wishes from India
ooo God 99% faster than all other and the explanation was very clear. love you man
Thank you So much.Your explanation was the best . Great teaching skills.
@DataDaft
3 жыл бұрын
Glad it was helpful!
Thank you so much! This is amazing.
tysm you explanation is very clear and easy to understand
Please add more leetcode question..really liked your explanations
Great explanation! Tks
omg best explanation ever
Thank you so much ! :)
Thank you
thank you!!
Thank you.
for this example what python libraries in basics we have to study...and is this kind of examples are asked in FAANG interviews?
Thanks. You can further simplify your idea as follows - class Solution: def lengthOfLongestSubstring(self, s: str) -> int: i = 0 max_length = 0 seen = dict() for j in range(len(s)): if s[j] in seen.keys(): i = max(i, seen[s[j]] + 1) seen[s[j]] = j else: seen[s[j]] = j if j - i + 1 > max_length: max_length = j - i + 1 return max_length
Could we expect more such videos (leetcode problems)in future ???
How do you return the string of that longest unique substring then?
Do more leetcode questions please
Thanks :)
Very nicely explained. And idk if it's just me who relates you with Sheldon! :P
@ryanmanchikanti5265
3 жыл бұрын
i thought that too ! wow.
can anyone explain how it works when the character 'a' gets repeated in his example cuz sub[a] will be 0 and wont satisfy the first condition sub[letter]>=curr_sub_start
your a great teacher but boy i hate these questions. i got my associates in software programming and im starting to hate it. do you think it just isnt for me and i didnt fully absorb what was needed. Even in the two numbers problem I am lost with what you are doing. I thought I was more of an artist and to use javascript and front end but i am stumped by that to. no matter how much i study it doesnt matter it seems i just dont get it. Any suggestions?
i have a question. If the ;length of s was 10 and we found a substring that was 6 and then there was a collision could we just assume that is the longest substring possible?
@DataDaft
3 жыл бұрын
No you can't do that because it depends on where the character that caused the collision appears in the substring. Consider this 10 character sequence: "abcdefazyx" The second "a" causes a collision after a substring of length 6, but the first "a" appears at the very beginning of the substring so there are could still be longer substrings, in this case a substring of length 9 exists: "bcdefazyx".
what does sub[letter] actually give? letter is a value. how can that give an indice?
How to print the longest substring with this code?
If I give the input string "cccc" the output is 2. It should have been 1. Also if the input is "cabccc" the output this code is showing = 4. When it should be 3. 🤔
my solution before looking up the answer was so so so close to being correct it's kind of upsetting hahah
@neotank874
3 жыл бұрын
same :(
pro
low key chris evans
@DataDaft
3 жыл бұрын
Wish I had a vibranium shield.
0 dislikes 😮😮😮