Lemonade Change - Leetcode 860 - Python

  Рет қаралды 7,191

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 39
@mohanedomer9081
@mohanedomer9081 2 ай бұрын
8:00 I have done 210 leetcode and cant miss one of your vids. You just make the problem enjoyable
@aanishas1925
@aanishas1925 2 ай бұрын
so true!
@yang5843
@yang5843 2 ай бұрын
I overcomplicated this problem, I thought this was going to be a harder version of coin change
@deepakjain4481
@deepakjain4481 2 ай бұрын
It was mentioned a easy question
@DNKF
@DNKF 2 ай бұрын
LC made my day finally!
@rahulsbhatt
@rahulsbhatt 2 ай бұрын
Thanks I didn't thought of them as bills and just calculated based on balance, I have to read the questions carefully.
@aanishas1925
@aanishas1925 2 ай бұрын
4:31 well, you read my mind
@mrvinyllad25
@mrvinyllad25 2 ай бұрын
i made the same mistake, then the same observations lol. Thank you for you service, Navdeep!
@jwsoftware
@jwsoftware 2 ай бұрын
Good observation on not needing to track the number of 20s. Took me from beats 44% runtime, 90% memory to 84% runtime, 96% memory. I thought I was missing some totally different solution at first but had everything else right
@Abdul_Rahman03
@Abdul_Rahman03 2 ай бұрын
I had misinterpreted the problem as well, then thought about dp while reading the problem, had to see the editorial turns out way more simple than I thought.
@Munchen888
@Munchen888 2 ай бұрын
It’s convenient to have a hashtable of size 2. And keep track of amount
@qulinxao
@qulinxao 2 ай бұрын
class Solution: def lemonadeChange(self, z: List[int],a=0,b=0) -> bool: for x in z: if x==5: a+=1;continue a-=1;b+=15-x;(b
@MP-ny3ep
@MP-ny3ep 2 ай бұрын
Thank you for the daily!
@sjnapoles2484
@sjnapoles2484 2 ай бұрын
This is such a nice problem
@mohammedkaifullakazim
@mohammedkaifullakazim 2 ай бұрын
Even i got the wrong answer at first when I read the question and coded it, means adding 5 dollars and giving back the remaining amount but, when I went through the example and understood it clearly possibly taking 10 to 15 min then I coded it, obviously the answer was correct
@АльбусДамблодр
@АльбусДамблодр 2 ай бұрын
always a calm chill day after a storm xD
@Yegory
@Yegory 2 ай бұрын
Bruh I didn't realize I needed to serve customer from left to right (queue), I just interpreted it as having all the bills right away and just giving change in whatever order. So this didn't pass [5,5,5,5,20,20,5,5,5,5]. Now I see why! :D
@pranav2423
@pranav2423 2 ай бұрын
Hey Neetcode, what drawing software do you use?
@leeroymlg4692
@leeroymlg4692 2 ай бұрын
paint 3D
@midhunskani
@midhunskani 2 ай бұрын
Much more simple Solution class Solution: def lemonadeChange(self, bills: List[int]) -> bool: count_5 = 0 count_10 = 0 for bill in bills: if bill == 5: count_5 += 1 elif bill == 10: count_10 += 1 count_5 -= 1 if count_5 < 0: return False elif bill == 20: if count_10 > 0 and count_5 > 0: count_10 -= 1 count_5 -= 1 elif count_5 >= 3: count_5 -= 3 else: return False return True
@kusumjoshi4613
@kusumjoshi4613 2 ай бұрын
good explanation
@jasurbekyuldoshev2673
@jasurbekyuldoshev2673 2 ай бұрын
Finally a problem in which I can breathe 😃
@pastori2672
@pastori2672 2 ай бұрын
please solve codeforces Increasing Sequence with Fixed OR 🙏
@Jk-ls7ey
@Jk-ls7ey 2 ай бұрын
I didn’t even think of dp or backtracking , i just did the same logic he did on my own. I don’t know i should be worried or not😭😭
@kartikgandhi7447
@kartikgandhi7447 2 ай бұрын
Me too 😭, I am also confused how did they think of dp or backtracking. This makes me worried and not worried at the same time lol.
@pastori2672
@pastori2672 2 ай бұрын
we're legit clones except when it comes to yesterday's problem
@limsiryuean5040
@limsiryuean5040 2 ай бұрын
I tried solving it using a dictionary, got stuck on trying to come up with a logic for the structure.
@user-tt3lb1yy6i
@user-tt3lb1yy6i 2 ай бұрын
10:21 is the runtime stat chart glitched? It seems that no matter the percentage beat, it always lands in that crevice
@asagiai4965
@asagiai4965 2 ай бұрын
I see. The hidden clue on what the question is. Is found in the note. "Note that you don't have any change in hand at first". (in other words you cannot give change someone correctly if you don't have the correct money in the first place) I'm gonna also probably answer this the wrong way if I don't see the video and the note.
@31redorange08
@31redorange08 2 ай бұрын
The problem would only be partially solvable if you didn't know how much change you had in the beginning.
@asagiai4965
@asagiai4965 2 ай бұрын
@@31redorange08 what does that even mean?
@31redorange08
@31redorange08 2 ай бұрын
@@asagiai4965 How would you solve it without knowing how much change you had in the beginning?
@asagiai4965
@asagiai4965 2 ай бұрын
@@31redorange08 idk if you are not getting my comment. But it is impossible not to know your change Change = your money - the price.
@31redorange08
@31redorange08 2 ай бұрын
@@asagiai4965 It seems like you're not understanding your own comment. You have to know how much money you have in the very beginning to know whether you can give everyone their change.
@AnkitaNallana
@AnkitaNallana 2 ай бұрын
Third, lol 😂
@c4rtel
@c4rtel 2 ай бұрын
first o_O
N-ary Tree Postorder Traversal - Leetcode 590 - Python
9:50
NeetCodeIO
Рет қаралды 7 М.
Why is everyone LYING?
7:56
NeetCodeIO
Рет қаралды 334 М.
У вас там какие таланты ?😂
00:19
Карина Хафизова
Рет қаралды 21 МЛН
Friends make memories together part 2  | Trà Đặng #short #bestfriend #bff #tiktok
00:18
Maximum Number of Points with Cost - Leetcode 1937 - Python
15:15
10 Math Concepts for Programmers
9:32
Fireship
Рет қаралды 1,9 МЛН
Gas Station - Greedy - Leetcode 134 - Python
15:47
NeetCode
Рет қаралды 139 М.
Being Competent With Coding Is More Fun
11:13
TheVimeagen
Рет қаралды 107 М.
Harder Than It Seems? 5 Minute Timer in C++
20:10
The Cherno
Рет қаралды 204 М.
The LeetCode Fallacy
6:08
NeetCode
Рет қаралды 567 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 539 М.
Maximum XOR for Each Query - Leetcode 1829 - Python
11:35
NeetCodeIO
Рет қаралды 5 М.
Coding Interviews Be Like
5:31
Nicholas T.
Рет қаралды 6 МЛН
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 139 М.