Dota2 Senate - Leetcode 649 - Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ธ.ค. 2024

ความคิดเห็น • 95

  • @NoNo-bc9ur
    @NoNo-bc9ur ปีที่แล้ว +63

    I think it should be:
    if rt < dt:
    R.append(rt + len(senate))
    else:
    D.append(dt + len(senate))
    Leetcode doesn't provide enough test cases so it doesn't catch the issue?

    • @monicakumar6769
      @monicakumar6769 ปีที่แล้ว +2

      you're right!

    • @NeetCodeIO
      @NeetCodeIO  ปีที่แล้ว +33

      Damn wtf your right. How'd I miss that.. and also how did LC?
      Just wanna clarify this was a code typo, I believe the drawing explanation was correct.

    • @sandeepvaid4275
      @sandeepvaid4275 ปีที่แล้ว +2

      @@NeetCodeIO Yeah man I this actually make me to see the video again and again . Like what logic is right .LOL

    • @kingKabali
      @kingKabali ปีที่แล้ว +1

      exactly, pls pin this

    • @_inspireverse___
      @_inspireverse___ ปีที่แล้ว

      Thanks man I was watching this portion again and again lol

  • @akarsan9121
    @akarsan9121 ปีที่แล้ว +56

    lmfao that was a good one "that's what she said" bro transitioned into the problem real quick at that..

  • @NeetCodeIO
    @NeetCodeIO  ปีที่แล้ว +34

    Looks like LC is doing a JavaScript-specific 30-day challenge, starting on May 5th. Do you guys want me to do it on this channel? Any frontenders here?
    Maybe I should make a poll hmmm
    leetcode.com/discuss/study-guide/3458761/Open-to-Registration!-30-Days-of-LC-JavaScript-Challenge

  • @saeedjinat9173
    @saeedjinat9173 ปีที่แล้ว +26

    - and guess what , all they can do is remove a 'D'.
    - well , where is the D ?
    - its right over here!
    - thats what she said .
    3:13 - the neetcode
    i almost fell down my chair laughing
    🤣🤣🤣🤣🤣🤣🤣🤣🤣

  • @MP-ny3ep
    @MP-ny3ep ปีที่แล้ว +18

    We missed you! Thanks for doing the daily leetcode challenges. Today's explanation was awesome.

  • @ruixue6955
    @ruixue6955 หลายเดือนก่อน

    2:34
    8:22 movement demo
    9:25 tricky part
    9:35

  • @SadgeZoomer
    @SadgeZoomer ปีที่แล้ว +10

    Ah I remember skipping classes in middle school and high school to play DotA AllStars. I gotta do this problem just for the nostalgia

    • @NeetCodeIO
      @NeetCodeIO  ปีที่แล้ว +14

      I never played dota but i feel like if you can learn that game then DSA is pretty simple in comparison lol.. I can never even tell wtf going on on screen

    • @JRK_RIDES
      @JRK_RIDES ปีที่แล้ว

      @@NeetCodeIO I can totally relate LOL

  • @Tim_desu
    @Tim_desu ปีที่แล้ว +2

    I would choose to see the NC's solution instead of the official one now
    This channel is amazing. Keep it up, bro.

  • @mixtli1975
    @mixtli1975 2 หลายเดือนก่อน

    I did it slightly differently. Single queue. Initialized it with the array. Also a Counter with count of D and R. And further, two counters for number of Rs and Ds that still need to be dropped, initialized to 0. popleft the queue in a loop, If the ban count for the current element is > 0, decrement it and skip the element. decrement the Counter for that party. Otherwise add to the ban count of the other party, and append it back to the queue. Check if the count for the other party is 0, you win. Return. Doesn't require indexes or two queues..

  • @atulraj219
    @atulraj219 ปีที่แล้ว +9

    Thats what she said 🤣

  • @Tyheir
    @Tyheir ปีที่แล้ว +1

    My first thought was to use a linked list and to change the pointers, this is a much simpler solution.

  • @arnabnandy2828
    @arnabnandy2828 ปีที่แล้ว +5

    You are awesome bro..
    Love from India

  • @shrirambalaji2915
    @shrirambalaji2915 ปีที่แล้ว +1

    Thank you so much,
    it was hard to understand the question it self for me,
    this video did helped

  • @sandippatel2518
    @sandippatel2518 ปีที่แล้ว

    Your approach is easy to understand and implement, your explanation is also awesome.

  • @the8426
    @the8426 ปีที่แล้ว +4

    LMAO that's what she said to you bc it was too small to find? HAHAHA I'm sorry I just had to, I love your sense of humor :)

  • @siranli
    @siranli ปีที่แล้ว

    Oh man, your solution is so great! I really appreciate your explanation.

  • @sanjeevrajora7335
    @sanjeevrajora7335 ปีที่แล้ว

    Thanks for your constant support, like always your explanation are really simple and straight forward even complex solution looks so easy

  • @nammi895
    @nammi895 6 หลายเดือนก่อน

    3:16 The 'D' is right over here, That's what she said 💀☠
    Bro I was watching this in 2x, it was hilarious, I almost missed that joke

  • @downtownsocialite1206
    @downtownsocialite1206 ปีที่แล้ว

    Wow, first time thinking is this way, great explanation.

  • @cytfvvytfvyggvryd
    @cytfvvytfvyggvryd ปีที่แล้ว +2

    Thanks for your awesome video. Could you explain that in line 17(line 19 as well), why it is R.append(dTurn + len(senate)) not R.append(rTurn+len(senate))? Thank you very much!

    • @HoppyGamer
      @HoppyGamer ปีที่แล้ว +3

      It should be as you say, Neet made an error, and somehow LC doesn't have all the necessary test cases that would catch this bug.

    • @cytfvvytfvyggvryd
      @cytfvvytfvyggvryd ปีที่แล้ว

      @@HoppyGamer Thank you for your reply! It helps me a lot!

  • @jiganeshpatil1472
    @jiganeshpatil1472 ปีที่แล้ว +1

    He thought we didnt notice

  • @amoghsv557
    @amoghsv557 ปีที่แล้ว +6

    that’s what she said 😭

  • @auroshisray9140
    @auroshisray9140 3 หลายเดือนก่อน

    Thanks buddy ❤

  • @mradulvarshney4495
    @mradulvarshney4495 ปีที่แล้ว +1

    3:17 that's what she said🙂🙂

  • @varuntyagi9610
    @varuntyagi9610 7 หลายเดือนก่อน

    lmao that random "that's what she said"

  • @vs3.14
    @vs3.14 ปีที่แล้ว

    Michael Scott aproves this 😂😂😂

  • @OneStopMusic.
    @OneStopMusic. ปีที่แล้ว +6

    Did anyone notice him saying "That's what she said"? or it's just me

  • @schangiz2002
    @schangiz2002 ปีที่แล้ว

    A quick question: the run time of the soln is O(n) or O(n log n)? I say o(n log n) because at each iteration of the while loop, we remove half of the senators.

  • @superlostgamer1608
    @superlostgamer1608 ปีที่แล้ว

    Thanks, really appreciate the effort

  • @Sulerhy
    @Sulerhy 7 หลายเดือนก่อน

    Firstly I thought about stack to solve this problem. But after that realized queue should be better. But I can not come up with the idea of 2 queues. How to come up with the solution is very challenging with greedy problems

  • @tsermon
    @tsermon ปีที่แล้ว

    Wow! What an elegant solution. I would've never come to this by myself

  • @ahmadbasyouni9173
    @ahmadbasyouni9173 3 หลายเดือนก่อน

    the thats what she said caught me off guard lmfao

  • @abd2518
    @abd2518 3 หลายเดือนก่อน

    3:15 michael scott fans represent

  • @riverbedrock
    @riverbedrock ปีที่แล้ว

    Shouldn’t it be R.append(rTurn+len(senate)) and similarly for D queue? If I am right why does your code still work?

  • @360liquidelectricity
    @360liquidelectricity 5 หลายเดือนก่อน

    I wish your videos where leetcode editorials.

  • @sidheartgadekar
    @sidheartgadekar ปีที่แล้ว +3

    Lmao thats what she said

  • @patrikm8389
    @patrikm8389 10 หลายเดือนก่อน

    what's the logic between adding R.append(dTurn +len(senate)) instead of rTurn+len(senate) and same logic for D.append?
    Tried with rTurn+len(senate) and it was the same. but don't get the logic

  • @productivityaccount8274
    @productivityaccount8274 หลายเดือนก่อน

    3:16 thats what she said🤣🤣

  • @vishnuvardhan2687
    @vishnuvardhan2687 ปีที่แล้ว +7

    Aliens 👽👽 attendance taken by here

  • @edwardteach2
    @edwardteach2 6 หลายเดือนก่อน

    U a Senate God

  • @Star_Bawa9
    @Star_Bawa9 ปีที่แล้ว

    public class Solution {
    public String predictPartyVictory(String senate) {
    int score = 0; // +ve for R and -ve for D
    StringBuilder sb = new StringBuilder(senate);
    for (int i = 0; i < sb.length(); ++i) {
    char ch = sb.charAt(i);
    if (ch == 'R') {
    if (score < 0)
    sb.append('D');
    ++score;
    } else {
    if (score > 0)
    sb.append('R');
    --score;
    }
    }
    return score > 0 ? "Radiant" : "Dire";
    }
    } i think this solution is also easy to understand

  • @nikhil199029
    @nikhil199029 ปีที่แล้ว +1

    That's what she said😂

  • @mohithadiyal6083
    @mohithadiyal6083 ปีที่แล้ว

    Amazing 😊

  • @PiyushYadav-pl9jm
    @PiyushYadav-pl9jm 3 หลายเดือนก่อน

    rturn and dturn seems to be reversed while enqueueing in simulation

  • @shubhamkumbhare2725
    @shubhamkumbhare2725 ปีที่แล้ว

    Thats what she said

  • @hypermeero4782
    @hypermeero4782 ปีที่แล้ว

    am i the only one who noticed him saying this 3:16

  • @SM-si2ky
    @SM-si2ky 11 หลายเดือนก่อน

    This problem has almost nothing abt Dota 2 lol just the names Radiant & Dire XDD

  • @kushagarsharma4783
    @kushagarsharma4783 6 หลายเดือนก่อน

    Definitely not medium i would say

  • @АльбусДамблодр
    @АльбусДамблодр ปีที่แล้ว

    damn its sick

  • @uptwist2260
    @uptwist2260 ปีที่แล้ว

    🙏

  • @DronaMBM
    @DronaMBM ปีที่แล้ว

    r for republicans and d for democrates

  • @kingKabali
    @kingKabali ปีที่แล้ว

    Republicans and Democrats.

  • @pratikgehlot1973
    @pratikgehlot1973 ปีที่แล้ว

    awesome use "thats what she said"

  • @yyppskcodes
    @yyppskcodes ปีที่แล้ว +8

    The fact you used the example "RRDDD" shows that you might have tried Count the votes method and failed
    🥲 "70 / 82 test cases passed"

  • @XEQUTE
    @XEQUTE 11 หลายเดือนก่อน

    Icefrog 🐸🧊

  • @abd2518
    @abd2518 3 หลายเดือนก่อน

    3:15 michael scott fans represent