Dota2 Senate - Leetcode 649 - Python

  Рет қаралды 21,894

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 93
@NoNo-bc9ur
@NoNo-bc9ur Жыл бұрын
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 Жыл бұрын
you're right!
@NeetCodeIO
@NeetCodeIO Жыл бұрын
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 Жыл бұрын
@@NeetCodeIO Yeah man I this actually make me to see the video again and again . Like what logic is right .LOL
@kingKabali
@kingKabali Жыл бұрын
exactly, pls pin this
@_inspireverse___
@_inspireverse___ Жыл бұрын
Thanks man I was watching this portion again and again lol
@akarsan9121
@akarsan9121 Жыл бұрын
lmfao that was a good one "that's what she said" bro transitioned into the problem real quick at that..
@saeedjinat9173
@saeedjinat9173 Жыл бұрын
- 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 Жыл бұрын
We missed you! Thanks for doing the daily leetcode challenges. Today's explanation was awesome.
@NeetCodeIO
@NeetCodeIO Жыл бұрын
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
@CongNguyen-og3iz
@CongNguyen-og3iz Жыл бұрын
Yes 🙌
@datopotatogames6885
@datopotatogames6885 Жыл бұрын
id be down for it
@sudiptamaity-e
@sudiptamaity-e Жыл бұрын
yes
@def__init
@def__init Жыл бұрын
Sorry no offence to JS devs but the daily algo problems are really enjoyable
@alanwu2693
@alanwu2693 Жыл бұрын
yes please!
@SadgeZoomer
@SadgeZoomer Жыл бұрын
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 Жыл бұрын
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
@mixtli1975
@mixtli1975 8 күн бұрын
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..
@Tim_desu
@Tim_desu Жыл бұрын
I would choose to see the NC's solution instead of the official one now This channel is amazing. Keep it up, bro.
@shrirambalaji2915
@shrirambalaji2915 Жыл бұрын
Thank you so much, it was hard to understand the question it self for me, this video did helped
@arnabnandy2828
@arnabnandy2828 Жыл бұрын
You are awesome bro.. Love from India
@atulraj219
@atulraj219 Жыл бұрын
Thats what she said 🤣
@sandippatel2518
@sandippatel2518 Жыл бұрын
Your approach is easy to understand and implement, your explanation is also awesome.
@Tyheir
@Tyheir Жыл бұрын
My first thought was to use a linked list and to change the pointers, this is a much simpler solution.
@sanjeevrajora7335
@sanjeevrajora7335 Жыл бұрын
Thanks for your constant support, like always your explanation are really simple and straight forward even complex solution looks so easy
@OneStopMusic.
@OneStopMusic. Жыл бұрын
Did anyone notice him saying "That's what she said"? or it's just me
@siranli
@siranli Жыл бұрын
Oh man, your solution is so great! I really appreciate your explanation.
@shaggyplayzz1439
@shaggyplayzz1439 Жыл бұрын
val = 0 i = 0 while i < len(senate): if senate[i] == 'D': if val < 0: senate += 'R' val += 1 else: if val > 0: senate += 'D' val -= 1 i += 1 return 'Dire' if val > 0 else 'Radiant' O(n) time complexity A reply is a whole for me sir
@NeetCodeIO
@NeetCodeIO Жыл бұрын
🫡
@the8426
@the8426 Жыл бұрын
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 :)
@NeetCodeIO
@NeetCodeIO Жыл бұрын
💀
@downtownsocialite1206
@downtownsocialite1206 Жыл бұрын
Wow, first time thinking is this way, great explanation.
@nammi895
@nammi895 4 ай бұрын
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
@amoghsv557
@amoghsv557 Жыл бұрын
that’s what she said 😭
@360liquidelectricity
@360liquidelectricity 3 ай бұрын
I wish your videos where leetcode editorials.
@Sulerhy
@Sulerhy 4 ай бұрын
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
@cytfvvytfvyggvryd
@cytfvvytfvyggvryd Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
He thought we didnt notice
@auroshisray9140
@auroshisray9140 Ай бұрын
Thanks buddy ❤
@tsermon
@tsermon Жыл бұрын
Wow! What an elegant solution. I would've never come to this by myself
@PiyushYadav-pl9jm
@PiyushYadav-pl9jm Ай бұрын
rturn and dturn seems to be reversed while enqueueing in simulation
@ahmadbasyouni9173
@ahmadbasyouni9173 Ай бұрын
the thats what she said caught me off guard lmfao
@varuntyagi9610
@varuntyagi9610 5 ай бұрын
lmao that random "that's what she said"
@sidheartgadekar
@sidheartgadekar Жыл бұрын
Lmao thats what she said
@superlostgamer1608
@superlostgamer1608 Жыл бұрын
Thanks, really appreciate the effort
@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.
@vs3.14
@vs3.14 Жыл бұрын
Michael Scott aproves this 😂😂😂
@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
@vishnuvardhan2687
@vishnuvardhan2687 Жыл бұрын
Aliens 👽👽 attendance taken by here
@NeetCodeIO
@NeetCodeIO Жыл бұрын
👾
@patrikm8389
@patrikm8389 8 ай бұрын
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
@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?
@abd2518
@abd2518 Ай бұрын
3:15 michael scott fans represent
@mradulvarshney4495
@mradulvarshney4495 Жыл бұрын
3:17 that's what she said🙂🙂
@kushagarsharma4783
@kushagarsharma4783 4 ай бұрын
Definitely not medium i would say
@edwardteach2
@edwardteach2 3 ай бұрын
U a Senate God
@SM-si2ky
@SM-si2ky 9 ай бұрын
This problem has almost nothing abt Dota 2 lol just the names Radiant & Dire XDD
@nikhil199029
@nikhil199029 Жыл бұрын
That's what she said😂
@mohithadiyal6083
@mohithadiyal6083 Жыл бұрын
Amazing 😊
@shubhamkumbhare2725
@shubhamkumbhare2725 Жыл бұрын
Thats what she said
@АльбусДамблодр
@АльбусДамблодр Жыл бұрын
damn its sick
@hypermeero4782
@hypermeero4782 Жыл бұрын
am i the only one who noticed him saying this 3:16
@uptwist2260
@uptwist2260 Жыл бұрын
🙏
@kingKabali
@kingKabali Жыл бұрын
Republicans and Democrats.
@DronaMBM
@DronaMBM Жыл бұрын
r for republicans and d for democrates
@yyppskcodes
@yyppskcodes Жыл бұрын
The fact you used the example "RRDDD" shows that you might have tried Count the votes method and failed 🥲 "70 / 82 test cases passed"
@niteshkushwaha9493
@niteshkushwaha9493 Жыл бұрын
That's why I am here.
@youknownothing_
@youknownothing_ Жыл бұрын
us
@pratikgehlot1973
@pratikgehlot1973 Жыл бұрын
awesome use "thats what she said"
@XEQUTE
@XEQUTE 8 ай бұрын
Icefrog 🐸🧊
@abd2518
@abd2518 Ай бұрын
3:15 michael scott fans represent
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 108 М.
Sentence Similarity III - Leetcode 1813 - Python
15:07
NeetCodeIO
Рет қаралды 7 М.
Incredible: Teacher builds airplane to teach kids behavior! #shorts
00:32
Fabiosa Stories
Рет қаралды 12 МЛН
Will A Guitar Boat Hold My Weight?
00:20
MrBeast
Рет қаралды 275 МЛН
РОДИТЕЛИ НА ШКОЛЬНОМ ПРАЗДНИКЕ
01:00
SIDELNIKOVVV
Рет қаралды 3,4 МЛН
Every parent is like this ❤️💚💚💜💙
00:10
Like Asiya
Рет қаралды 20 МЛН
Microservices are Technical Debt
31:59
NeetCodeIO
Рет қаралды 433 М.
Can you steal something that's already free?
11:48
NeetCodeIO
Рет қаралды 31 М.
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 312 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 406 М.
The LeetCode Fallacy
6:08
NeetCode
Рет қаралды 530 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 658 М.
Is Computer Science still worth it?
20:08
NeetCodeIO
Рет қаралды 369 М.
Maximize Score after N Operations - Leetcode 1799 - Python
18:20
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 244 М.
Incredible: Teacher builds airplane to teach kids behavior! #shorts
00:32
Fabiosa Stories
Рет қаралды 12 МЛН