LeetCode Backspace String Compare Solution Explained - Java

Поделиться
HTML-код
  • Опубликовано: 6 ноя 2024

Комментарии • 33

  • @CodeXplore
    @CodeXplore 4 года назад +12

    You re brilliant! Your explanation saved my days. I read so many solutions regarding to Space O(1) solution, but cant understand till watch your video. Thanks bro!!!

  • @iitnakanpur..
    @iitnakanpur.. 4 года назад +26

    who came after seeing this question on leetcode 30days coding challenge😅😅

  • @paramagurug9237
    @paramagurug9237 5 лет назад +11

    Nice job, pointer manipulation is little tricky but you got it right :)
    Another solution is to use the stack. Push the char into stack if it's not '#' otherwise pop if it's not empty. Repeat for both the strings and then compare the stacks.

    • @karenhuynh1355
      @karenhuynh1355 4 года назад +15

      A stack wouldn't be O(1) space

    • @saibeach
      @saibeach 2 года назад +1

      @@karenhuynh1355 hey bro, you make this place so serious, haha, joking, good point

  • @ashishmadan5700
    @ashishmadan5700 3 года назад +12

    This is not a easy catogery problem at all !! 😂😂

  • @god-speed03
    @god-speed03 4 года назад +4

    I like how you show that you've tried and failed many times before... Hope we meet at fang some day😁

  • @AnandKumar-kz3ls
    @AnandKumar-kz3ls 2 года назад +1

    i was doing the same thing but was not skipping the characters one by one. thanks nick

  • @treyquattro
    @treyquattro 4 года назад +2

    smart. I say that because I solved it the same way ;) However, instead of copy & paste I employed a lambda to find the next non-backspace character

  • @weirdbadminton6173
    @weirdbadminton6173 2 года назад +2

    Can you explain how it's time complexity is o(n) rather than o(n*2)

    • @MrSaurus
      @MrSaurus Год назад

      Because in time complexity, you drop the constants (any numbers) because as the input size gets bigger, the constant makes less of a difference. So for n*2, drop the 2 and you get n.

  • @Tlacoyo59a
    @Tlacoyo59a 4 года назад +4

    I just have the doubt of why do you decrease the skips.

    • @gokulakrishnanr8414
      @gokulakrishnanr8414 6 месяцев назад +1

      Something went wrong. Please try again or refresh the commment.

  • @mayanksrivastava4452
    @mayanksrivastava4452 4 года назад +2

    Thanks a lot for such a wonderful explanation, it would be great if you could create some course of all the leetcode and hackerRank problems explanation course - paid/unpaid that would be a great help to human society 😇🍺

  • @lex-zt6uc
    @lex-zt6uc 2 года назад +2

    Bro I know I am a bit late but please get some rest you look tired 😌

  • @openworld7585
    @openworld7585 4 года назад +1

    Thank you very much for this video

  • @kumarc4853
    @kumarc4853 3 года назад +1

    thanks Nick

  • @AnandKumar-kz3ls
    @AnandKumar-kz3ls 2 года назад +1

    you the man

  • @ashwathhegde8050
    @ashwathhegde8050 4 года назад +2

    may be using 2 stacks would be little easy to implement

    • @TheMichaelKao
      @TheMichaelKao 4 года назад +14

      true, but the problem want solvers to use O(1) space

  • @Historyiswatching
    @Historyiswatching 2 года назад +2

    How is this easy?!?! T_T

  • @justhaveempathybro
    @justhaveempathybro Год назад +1

    tricky

  • @vk1618
    @vk1618 4 года назад +1

    Review

  • @pulkitgupta3477
    @pulkitgupta3477 4 года назад +1

    can be implemented using stacks....

  • @kevalkishan3824
    @kevalkishan3824 4 года назад +2

    can be done through stack in 1 ms

    • @happycoding1093
      @happycoding1093 4 года назад +7

      stack is not space complexity O(1), the problem follow up wants you to solve it in space O(1), and this video is for that

    • @kevalkishan3824
      @kevalkishan3824 4 года назад +1

      @@happycoding1093 ooh now I got that....okk