Longest Substring Without Repeating Characters - Leetcode 3 - Sliding Window (Python)

Поділитися
Вставка
  • Опубліковано 14 жов 2024
  • 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/gah...
    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 UA-cam 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.ne...
    My Favorite Courses:
    Data Structures & Algorithms:
    UCalifornia San Diego DSA: imp.i384100.ne...
    Stanford Algorithms: imp.i384100.ne...
    Python Data Structures: imp.i384100.ne...
    Meta Coding Interview Prep: imp.i384100.ne...
    Python:
    UMichigan Python for Everybody: imp.i384100.ne...
    Python Mastery from MLNOW.ai: mlnow.ai/cours...
    Google IT Automation w/ Python: imp.i384100.ne...
    Web Dev / Full Stack:
    Meta Front-End Developer: imp.i384100.ne...
    IBM Full Stack Developer: imp.i384100.ne...
    Meta Back-End Developer: imp.i384100.ne...
    John Hopkins HTML, CSS & JS: imp.i384100.ne...
    IBM DevOps: imp.i384100.ne...
    Cloud Development:
    AWS Fundamentals: imp.i384100.ne...
    GCP Cloud Engineer: imp.i384100.ne...
    Microsoft Azure Fundamentals: imp.i384100.ne...
    Game Development:
    Michigan State Unity Development: imp.i384100.ne...
    UColorado C++ for Unreal Engine: www.coursera.o...
    SQL & Data Science:
    SQL by MLNOW.ai: mlnow.ai/cours...
    Python for Data Science by MLNOW.ai: mlnow.ai/cours...
    Google Data Analytics: imp.i384100.ne...
    IBM Data Science: imp.i384100.ne...
    IBM Data Engineer: imp.i384100.ne...
    Machine Learning & AI:
    ML Mastery at MLNOW.ai: mlnow.ai/cours...
    ML w/ Andrew Ng: www.coursera.o...
    Deep Learning w/ Andrew Ng: imp.i384100.ne...

КОМЕНТАРІ • 23

  • @GregHogg
    @GregHogg  2 місяці тому +1

    Master Data Structures & Algorithms For FREE at AlgoMap.io!

  • @vaibhavchetri8819
    @vaibhavchetri8819 15 днів тому +1

    Best Explanation. Its Crystal Clear

  • @pumpkinp6906
    @pumpkinp6906 7 місяців тому +4

    Great explanation ! It would be great if you would share the leetcode problem link in description so that we can implement ourselves after learning

  • @HussainAli-hn2ef
    @HussainAli-hn2ef Місяць тому +1

    great explanation!

  • @middle-agedclimber
    @middle-agedclimber 4 місяці тому +3

    Best solution I've seen. Thanks

  • @ryan.aquino
    @ryan.aquino 12 днів тому +1

    Get the length of the set instead when comparing. Much easier to think intuitively

  • @kashinathpatekar9870
    @kashinathpatekar9870 7 місяців тому +4

    Technically the size of the set will be limited by the character set used, so can we call it O(1) space?

    • @GregHogg
      @GregHogg  7 місяців тому +4

      Oops did I say O(n) space? You're completely correct, yes!

    • @kashinathpatekar9870
      @kashinathpatekar9870 7 місяців тому

      Thanks for clarifying!

    • @foudilbenouci482
      @foudilbenouci482 4 місяці тому

      more exactly O(n/c) where c is the capacity of the character set used and n the size of the string

    • @shashank5175
      @shashank5175 Місяць тому

      @@foudilbenouci482 O(n/c) could be reduced to O(n) or am I wrong cause I thought you can reduce multiplication and division but can reduce addition and subtraction

  • @HelicopterRidesForCommunists
    @HelicopterRidesForCommunists 3 місяці тому

    Best solution Ive seen. Nice!

  • @pravuchaudhary3904
    @pravuchaudhary3904 Місяць тому

    I have two questions:
    1. insted of while loop , why not use if...else
    2. after while loop: instead of removing and updating the char in sett, why not add string in sett first and start update "longest"

  • @yuasufhelal7181
    @yuasufhelal7181 3 місяці тому

    It's a basic one but please I have question what if we use if s(r) in seen willl it be completely wrong but by what sense. Since you were using while.

  • @DamosyTheFreckle
    @DamosyTheFreckle 4 місяці тому

    Good explanation, thank you!

  • @rajarshibiswas9424
    @rajarshibiswas9424 3 місяці тому

    i don't know why the code I have written is exactly same instead of set I used hash map should i have used hash set?? is hash map is the main cause of output limit exceeded??

  • @ParaSteve1985
    @ParaSteve1985 7 місяців тому

    Hi there, are you still available for 1o1 trainings sessions?

    • @GregHogg
      @GregHogg  7 місяців тому +1

      Yes, please email greg.hogg1@outlook.com

    • @ParaSteve1985
      @ParaSteve1985 6 місяців тому

      @@GregHogg done, waiting for your reply.

  • @sumeethraikar711
    @sumeethraikar711 Місяць тому

    set doesnt preserve insertion order. so how removing of elements is working here.?

    • @freshedits8408
      @freshedits8408 Місяць тому

      They are removing based on the actual character, but not with an index so it is working.