Champagne Tower - Leetcode 799 - Python

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 27. 07. 2024
  • 🚀 neetcode.io/ - A better way to prepare for Coding Interviews
    đŸ„· Discord: / discord
    🐩 Twitter: / neetcode1
    🐼 Support the channel: / neetcode
    ⭐ BLIND-75 PLAYLIST: ‱ Two Sum - Leetcode 1 -...
    💡 DYNAMIC PROGRAMMING PLAYLIST: ‱ House Robber - Leetco...
    Problem Link: leetcode.com/problems/champag...
    0:00 - Read the problem
    0:30 - Drawing Explanation
    8:45 - Coding Explanation
    leetcode 799
    #neetcode #leetcode #python

Komentáƙe • 28

  • @kelvinology4
    @kelvinology4 Pƙed 10 měsĂ­ci +5

    highly recommend all of you to do leetcode 118 - 120 (neetcode has all explanation videos)
    the structure is pretty similar that all of them are dealing with triangles
    btw great explanation and your solutions always inspire me, thanks a lotđŸ™đŸ»

  • @bundiderp5109
    @bundiderp5109 Pƙed 10 měsĂ­ci +10

    Great explanation as always. But I found the 44.5 overflow at 4:40 to be very confusing. I am pretty sure it should be 49.5 as 2x 49.5 = 99.

    • @NeetCodeIO
      @NeetCodeIO  Pƙed 10 měsĂ­ci

      Yep, my math was way off, sorry about that!

  • @akash-kumar737
    @akash-kumar737 Pƙed 10 měsĂ­ci +1

    I coded after following your explaination and my code is exactly similar. Thanks dude. I have recently started doing Leedcode daily for last 5 days.

  • @J1MKAKA1N
    @J1MKAKA1N Pƙed 10 měsĂ­ci

    Simple and elegant, thanks for the effort! Keep it going :)

  • @il5083
    @il5083 Pƙed 10 měsĂ­ci +1

    I was worrying about some champagne will reach the end first. Didn’t think of processing it row by row is possible. Great explanation, thanks!

  • @VidyaBhandary
    @VidyaBhandary Pƙed 10 měsĂ­ci

    Superb Explanation ...

  • @user-sx7zc3ez4w
    @user-sx7zc3ez4w Pƙed 10 měsĂ­ci

    It's literally NEET CODE! Thank you

  • @AmanRaj-yn5pj
    @AmanRaj-yn5pj Pƙed 10 měsĂ­ci

    nice way of explaining👍

  • @tenzin8773
    @tenzin8773 Pƙed 9 měsĂ­ci +1

    Don't think I'll ever be able to solve this in a real interview if I never did this question before :(

  • @Harish-rz4gv
    @Harish-rz4gv Pƙed 10 měsĂ­ci +6

    Kinda Pascal's triangle

  • @darkcaper703
    @darkcaper703 Pƙed 10 měsĂ­ci +7

    847. Shortest Path Visiting All Nodes :(

    • @themagickalmagickman
      @themagickalmagickman Pƙed 10 měsĂ­ci

      bfs with bitmask instead of set. Look up how to do a bitmask, its actually surprisingly easy. The intuitive approach is to bfs because we want a shortest path, each bfs node will need to maintain a visited set though. Instead of an actual set, we use an integer bitmask. As you know, integers are represented as binary, ex: 00101. If we assign each node to a position in the binary representation, we can mark it visited by flipping the digit from 0 to 1. This yields a unique integer for each visited set. So If I want to mark the 0th node as visited my bitmask looks like this: 0001 (4 nodes total, 0,1,2,3). This yields the integer 1. Set the 0 and 3rd visited? 1001, int = 9.
      Here is the operation for setting a given bit as visited, bitmask |= (1

  • @memeproductions4182
    @memeproductions4182 Pƙed 10 měsĂ­ci

    did the same, but i basically consider this a BFS where each row is a level of the tree

  • @SD-vk3ko
    @SD-vk3ko Pƙed 10 měsĂ­ci

    Thanks lord, we have you!!🙂

  • @phpostrich
    @phpostrich Pƙed 10 měsĂ­ci

    this one was pretty cool

  • @anantom251
    @anantom251 Pƙed 10 měsĂ­ci

    You are the saviour.

  • @satviksrinivas8764
    @satviksrinivas8764 Pƙed 7 měsĂ­ci

    If poured was fixed could there be a DP solution? I'm thinking along the lines that you would have a base case since you know the total amount of champagne.

  • @phpostrich
    @phpostrich Pƙed 10 měsĂ­ci

    another one already wowz

  • @anshror2583
    @anshror2583 Pƙed 10 měsĂ­ci +1

    Bro please upload leetcode video daily

  • @boisaulit
    @boisaulit Pƙed 5 měsĂ­ci

    Genius.

  • @aazzrwadrf
    @aazzrwadrf Pƙed 10 měsĂ­ci +2

    pretty hard for a med

  • @danielsun716
    @danielsun716 Pƙed 10 měsĂ­ci

    looks like the dp problem

  • @StellasAdi18
    @StellasAdi18 Pƙed 10 měsĂ­ci

    Guess you meant 49.5 and not 44.5 at 5.08 for 100 example.

  • @silent7152
    @silent7152 Pƙed 10 měsĂ­ci

    i thought it was a dp problem

    • @haroldobasi2545
      @haroldobasi2545 Pƙed 10 měsĂ­ci

      Same, spent forever trying to think of a base case. I guess sometimes the most straightforward solutions are the right ones

    • @MrKB_SSJ2
      @MrKB_SSJ2 Pƙed 10 měsĂ­ci

      lol

  • @SeanBow-fs7rj
    @SeanBow-fs7rj Pƙed 10 měsĂ­ci

    ebat' traxatel