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

  • @josephstalin9481
    @josephstalin94813 жыл бұрын

    Best Explanation ever you are the indian youtuber of leetcode

  • @davidutomi5737
    @davidutomi57373 жыл бұрын

    The legit GOAT. Explanations always soo good. Thank you!

  • @adventurer2395
    @adventurer2395 Жыл бұрын

    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.

  • @kacakacamu
    @kacakacamu Жыл бұрын

    amazing job. please continue to these practices, I'm learning a lot

  • @annas8308
    @annas83083 жыл бұрын

    Please make more awesome videos like this, DataDaft!

  • @loden5677
    @loden56772 жыл бұрын

    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

  • @punstress
    @punstress4 жыл бұрын

    Are you kidding, 0 comments, only 7 upvotes? LIked and subscribed and hoping to see more.

  • @neotank874
    @neotank8743 жыл бұрын

    When I saw the program faster than 99.37% and memory usage less than 100%, I immediately hit the subscribe button.

  • @mariohage1090
    @mariohage10903 жыл бұрын

    Thank you sir. Just starting out with leetcode after a few MOOCs, and this is very helpful. Appreciate it!

  • @DataDaft

    @DataDaft

    3 жыл бұрын

    Glad to be of service. =)

  • @mryup6100
    @mryup61007 ай бұрын

    Nice! What you mentioned about measuring the run time of a solution before writing code is really valuable advice!

  • @biluulu8896
    @biluulu88963 жыл бұрын

    loved it, very clear explanation! thank you!

  • @alkeshace6158
    @alkeshace61583 жыл бұрын

    Its very helpful, please keep making more. Great Work

  • @winterresearch
    @winterresearch4 жыл бұрын

    Clear solution, commenting to support this type of content

  • @NitinSatish
    @NitinSatish3 жыл бұрын

    Thank you. Your explanation is awesome!

  • @sreejaroy8463
    @sreejaroy84633 жыл бұрын

    please upload more leetcode problem solutions. Loved your teaching skills! Best wishes from India

  • @workhardforyourfamily4826
    @workhardforyourfamily4826 Жыл бұрын

    ooo God 99% faster than all other and the explanation was very clear. love you man

  • @smritipradhan6921
    @smritipradhan69213 жыл бұрын

    Thank you So much.Your explanation was the best . Great teaching skills.

  • @DataDaft

    @DataDaft

    3 жыл бұрын

    Glad it was helpful!

  • @tesfatsionshiferaw3474
    @tesfatsionshiferaw34743 жыл бұрын

    Thank you so much! This is amazing.

  • @ritikasingh6298
    @ritikasingh62983 ай бұрын

    tysm you explanation is very clear and easy to understand

  • @kshitijkhurana2697
    @kshitijkhurana26973 жыл бұрын

    Please add more leetcode question..really liked your explanations

  • @paraquedoido5304
    @paraquedoido53044 жыл бұрын

    Great explanation! Tks

  • @az-ic8vj
    @az-ic8vj4 жыл бұрын

    omg best explanation ever

  • @akhilajakkam269
    @akhilajakkam2693 жыл бұрын

    Thank you so much ! :)

  • @mehrdadmirpourian64
    @mehrdadmirpourian642 жыл бұрын

    Thank you

  • @izzakhan7971
    @izzakhan79713 жыл бұрын

    thank you!!

  • @nicholascarmello1778
    @nicholascarmello17783 жыл бұрын

    Thank you.

  • @prashantshinde5318
    @prashantshinde53182 жыл бұрын

    for this example what python libraries in basics we have to study...and is this kind of examples are asked in FAANG interviews?

  • @ogsconnect1312
    @ogsconnect13124 жыл бұрын

    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

  • @kishankumar-pn3tj
    @kishankumar-pn3tj10 ай бұрын

    Could we expect more such videos (leetcode problems)in future ???

  • @hkmelody5047
    @hkmelody50472 жыл бұрын

    How do you return the string of that longest unique substring then?

  • @RohitSingh-bh6kb
    @RohitSingh-bh6kb4 жыл бұрын

    Do more leetcode questions please

  • @evynsrefuge
    @evynsrefuge3 жыл бұрын

    Thanks :)

  • @tanvikale1519
    @tanvikale15193 жыл бұрын

    Very nicely explained. And idk if it's just me who relates you with Sheldon! :P

  • @ryanmanchikanti5265

    @ryanmanchikanti5265

    3 жыл бұрын

    i thought that too ! wow.

  • @darktrigo6475
    @darktrigo6475 Жыл бұрын

    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

  • @KingdomCre8tive
    @KingdomCre8tive Жыл бұрын

    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?

  • @omars9263
    @omars92633 жыл бұрын

    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

    @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".

  • @sangpark7656
    @sangpark7656 Жыл бұрын

    what does sub[letter] actually give? letter is a value. how can that give an indice?

  • @akhibali8405
    @akhibali8405 Жыл бұрын

    How to print the longest substring with this code?

  • @sreejaroy8463
    @sreejaroy84632 жыл бұрын

    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. 🤔

  • @BBoPPo88
    @BBoPPo883 жыл бұрын

    my solution before looking up the answer was so so so close to being correct it's kind of upsetting hahah

  • @neotank874

    @neotank874

    3 жыл бұрын

    same :(

  • @joyo2122
    @joyo21223 жыл бұрын

    pro

  • @satishkumarsajjan2132
    @satishkumarsajjan21323 жыл бұрын

    low key chris evans

  • @DataDaft

    @DataDaft

    3 жыл бұрын

    Wish I had a vibranium shield.

  • @buradanaveen2838
    @buradanaveen28383 жыл бұрын

    0 dislikes 😮😮😮

Келесі