Lemonade Change - Leetcode 860 - Python

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

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
@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
@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.
@DNKF
@DNKF 2 ай бұрын
LC made my day finally!
@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
@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!
@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
@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
@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
@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
@MP-ny3ep
@MP-ny3ep 2 ай бұрын
Thank you for the daily!
@sjnapoles2484
@sjnapoles2484 2 ай бұрын
This is such a nice problem
@АльбусДамблодр
@АльбусДамблодр 2 ай бұрын
always a calm chill day after a storm xD
@kusumjoshi4613
@kusumjoshi4613 2 ай бұрын
good explanation
@pranav2423
@pranav2423 2 ай бұрын
Hey Neetcode, what drawing software do you use?
@leeroymlg4692
@leeroymlg4692 2 ай бұрын
paint 3D
@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.
@jasurbekyuldoshev2673
@jasurbekyuldoshev2673 2 ай бұрын
Finally a problem in which I can breathe 😃
@limsiryuean5040
@limsiryuean5040 2 ай бұрын
I tried solving it using a dictionary, got stuck on trying to come up with a logic for the structure.
@pastori2672
@pastori2672 2 ай бұрын
please solve codeforces Increasing Sequence with Fixed OR 🙏
@pastori2672
@pastori2672 2 ай бұрын
we're legit clones except when it comes to yesterday's problem
@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 М.
Most Beautiful Item for Each Query - Leetcode 2070 - Python
17:17
КОГДА К БАТЕ ПРИШЕЛ ДРУГ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 7 МЛН
amazing#devil #lilith #funny #shorts
00:15
Devil Lilith
Рет қаралды 18 МЛН
They Chose Kindness Over Abuse in Their Team #shorts
00:20
I migliori trucchetti di Fabiosa
Рет қаралды 12 МЛН
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 2 МЛН
Regions Cut By Slashes - Leetcode 959 - Python
16:06
NeetCodeIO
Рет қаралды 17 М.
Assign Cookies - Leetcode 455 - Python
9:06
NeetCodeIO
Рет қаралды 18 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 268 М.
How I Approach a New Leetcode Problem (live problem solving)
25:31
10 Math Concepts for Programmers
9:32
Fireship
Рет қаралды 1,9 МЛН
Harder Than It Seems? 5 Minute Timer in C++
20:10
The Cherno
Рет қаралды 209 М.
A Day in the Life of a Software Engineer... WFH
9:24
PIRATE KING
Рет қаралды 9 МЛН
I Solved 100 LeetCode Problems
13:11
Green Code
Рет қаралды 216 М.
why are switch statements so HECKIN fast?
11:03
Low Level
Рет қаралды 425 М.
Why is everyone LYING?
7:56
NeetCodeIO
Рет қаралды 336 М.
КОГДА К БАТЕ ПРИШЕЛ ДРУГ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 7 МЛН