Split a String Into the Max Number of Unique Substrings - Leetcode 1593 - Python

Поділитися
Вставка
  • Опубліковано 20 жов 2024

КОМЕНТАРІ • 19

  • @NeetCodeIO
    @NeetCodeIO  5 годин тому +8

    Don't worry, papa neetcode is here
    Btw I recently launched a course where you can learn Postgres with 75 interactive lessons. Writing code is the best way to learn and neetcode.io makes that easy for you do to. NC Pro members automatically have access to all courses.

  • @nolanstutelberg3900
    @nolanstutelberg3900 Годину тому +6

    Just last week went from a 100k to a 240k SWE job because of these videos. Thanks for everything you do papa neetcode

  • @CodeTom-i1t
    @CodeTom-i1t 5 годин тому +5

    2 Highlights of the video:
    1:00 "papa neetcode" 🫶
    1:08 voice crack 🤡

    • @CodeTom-i1t
      @CodeTom-i1t 5 годин тому +1

      Jk great video as usual, just got an excuse to comment lol

    • @NeetCodeIO
      @NeetCodeIO  5 годин тому +2

      My voice cracks a lot I usually edit it out 🫠

  • @manchie18
    @manchie18 4 години тому

    Thank you so much for making these videos, I started learning to program this year and was at the point where code just looked like magic, but now I can follow along and have a good idea of how you’ll implement the code! Youre the man

  • @santanu29
    @santanu29 Годину тому

    You can remove the substr by maintaining a str variable, and appending a char at every iteration for the loop.

  • @MP-ny3ep
    @MP-ny3ep Годину тому

    Beautiful explanation. Thank you !

  • @realisticlevel2553
    @realisticlevel2553 Годину тому

    I went for the greedy approach first :(((((((
    Anyways, thank you Neetcode!

  • @bevvy.bee9
    @bevvy.bee9 4 години тому +1

    Hearing "papa neetcode" was not on my bingo list 😭

  • @RomaMotwani
    @RomaMotwani 4 години тому

    could you start giving an alternative dry run of codes in java and c++ too?

  • @satyadheeraj6081
    @satyadheeraj6081 Годину тому

    I didn't quite get why substr had to be removed from cur_set after dfs call. Doesn't that defeat the whole purpose of finding duplicates? Can someone please explain?

    • @arjunreddy2647
      @arjunreddy2647 42 хвилини тому

      bro because when u backtrack u go back to a state where u haven’t seen it before like yeah u might have made the choice for substring “ab” but after u made that choice and backtrack u need to remove the rest of what u have seen after exploring it because u r at new state

  • @daleyfraser6993
    @daleyfraser6993 5 годин тому

    thanks for help papa. needed it for that daily streak (hehe my name also Daley)

  • @janaSdj
    @janaSdj 33 хвилини тому

    Nice..

  • @SurajSingh-mf3vz
    @SurajSingh-mf3vz 4 години тому

    Why are you slicing substr in every iteration in the loop?

  • @jamesisaacson6414
    @jamesisaacson6414 5 годин тому

    HELP ME Please! I have no clue at all why the following does not work. Fails for the input "wwwzfvedwfvhsww"
    def maxUniqueSplit(self, s: str) -> int:
    if len(s) == 1:
    return 1
    counter = set()
    def helper(start, end):
    if end > len(s):
    return 0
    if start == len(s):
    return 0
    curr_string = s[start:end]
    if curr_string in counter:
    return 0
    counter.add(curr_string)
    does_end = 1 + helper(end, end+1)
    counter.remove(curr_string)
    doesnot_end = helper(start, end + 1)
    return max(doesnot_end, does_end)
    return helper(0, 1)

  • @EverAfterBreak2
    @EverAfterBreak2 3 години тому

    Papá ❤

  • @xieandy
    @xieandy 5 годин тому

    papa neetcode