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?
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
- 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 🤣🤣🤣🤣🤣🤣🤣🤣🤣
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
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..
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!
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.
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
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
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
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?
you're right!
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.
@@NeetCodeIO Yeah man I this actually make me to see the video again and again . Like what logic is right .LOL
exactly, pls pin this
Thanks man I was watching this portion again and again lol
lmfao that was a good one "that's what she said" bro transitioned into the problem real quick at that..
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
Yes 🙌
id be down for it
yes
Sorry no offence to JS devs but the daily algo problems are really enjoyable
yes please!
- 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
🤣🤣🤣🤣🤣🤣🤣🤣🤣
We missed you! Thanks for doing the daily leetcode challenges. Today's explanation was awesome.
2:34
8:22 movement demo
9:25 tricky part
9:35
Ah I remember skipping classes in middle school and high school to play DotA AllStars. I gotta do this problem just for the nostalgia
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
@@NeetCodeIO I can totally relate LOL
I would choose to see the NC's solution instead of the official one now
This channel is amazing. Keep it up, bro.
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..
Thats what she said 🤣
My first thought was to use a linked list and to change the pointers, this is a much simpler solution.
You are awesome bro..
Love from India
Thank you so much,
it was hard to understand the question it self for me,
this video did helped
Your approach is easy to understand and implement, your explanation is also awesome.
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 :)
💀
Oh man, your solution is so great! I really appreciate your explanation.
Thanks for your constant support, like always your explanation are really simple and straight forward even complex solution looks so easy
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
Wow, first time thinking is this way, great explanation.
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!
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.
@@HoppyGamer Thank you for your reply! It helps me a lot!
He thought we didnt notice
that’s what she said 😭
Thanks buddy ❤
3:17 that's what she said🙂🙂
lmao that random "that's what she said"
Michael Scott aproves this 😂😂😂
Did anyone notice him saying "That's what she said"? or it's just me
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.
Thanks, really appreciate the effort
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
Wow! What an elegant solution. I would've never come to this by myself
the thats what she said caught me off guard lmfao
3:15 michael scott fans represent
Shouldn’t it be R.append(rTurn+len(senate)) and similarly for D queue? If I am right why does your code still work?
I wish your videos where leetcode editorials.
Lmao thats what she said
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
3:16 thats what she said🤣🤣
Aliens 👽👽 attendance taken by here
👾
U a Senate God
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
That's what she said😂
Amazing 😊
rturn and dturn seems to be reversed while enqueueing in simulation
Thats what she said
am i the only one who noticed him saying this 3:16
This problem has almost nothing abt Dota 2 lol just the names Radiant & Dire XDD
Definitely not medium i would say
damn its sick
🙏
r for republicans and d for democrates
Republicans and Democrats.
awesome use "thats what she said"
The fact you used the example "RRDDD" shows that you might have tried Count the votes method and failed
🥲 "70 / 82 test cases passed"
That's why I am here.
us
Icefrog 🐸🧊
3:15 michael scott fans represent