Lemonade Change - Leetcode 860 - Python

  Рет қаралды 6,820

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 40
@mohanedomer9081
@mohanedomer9081 Ай бұрын
8:00 I have done 210 leetcode and cant miss one of your vids. You just make the problem enjoyable
@aanishas1925
@aanishas1925 Ай бұрын
so true!
@yang5843
@yang5843 Ай бұрын
I overcomplicated this problem, I thought this was going to be a harder version of coin change
@abhayrajsingh4707
@abhayrajsingh4707 Ай бұрын
Me too😓
@deepakjain4481
@deepakjain4481 Ай бұрын
It was mentioned a easy question
@DNKF
@DNKF Ай бұрын
LC made my day finally!
@aanishas1925
@aanishas1925 Ай бұрын
4:31 well, you read my mind
@rahulsbhatt
@rahulsbhatt Ай бұрын
Thanks I didn't thought of them as bills and just calculated based on balance, I have to read the questions carefully.
@Abdul_Rahman03
@Abdul_Rahman03 Ай бұрын
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 Ай бұрын
It’s convenient to have a hashtable of size 2. And keep track of amount
@jwsoftware
@jwsoftware Ай бұрын
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
@mrvinyllad25
@mrvinyllad25 Ай бұрын
i made the same mistake, then the same observations lol. Thank you for you service, Navdeep!
@sjnapoles2484
@sjnapoles2484 Ай бұрын
This is such a nice problem
@mohammedkaifullakazim
@mohammedkaifullakazim Ай бұрын
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
@user-dp9gi1vg8r
@user-dp9gi1vg8r Ай бұрын
always a calm chill day after a storm xD
@pastori2672
@pastori2672 Ай бұрын
please solve codeforces Increasing Sequence with Fixed OR 🙏
@kusumjoshi4613
@kusumjoshi4613 Ай бұрын
good explanation
@qulinxao
@qulinxao Ай бұрын
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 Ай бұрын
Thank you for the daily!
@Yegory
@Yegory Ай бұрын
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
@midhunskani
@midhunskani Ай бұрын
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
@pranav2423
@pranav2423 Ай бұрын
Hey Neetcode, what drawing software do you use?
@leeroymlg4692
@leeroymlg4692 Ай бұрын
paint 3D
@jasurbekyuldoshev2673
@jasurbekyuldoshev2673 Ай бұрын
Finally a problem in which I can breathe 😃
@limsiryuean5040
@limsiryuean5040 Ай бұрын
I tried solving it using a dictionary, got stuck on trying to come up with a logic for the structure.
@Jk-ls7ey
@Jk-ls7ey Ай бұрын
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 Ай бұрын
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 Ай бұрын
we're legit clones except when it comes to yesterday's problem
@user-tt3lb1yy6i
@user-tt3lb1yy6i Ай бұрын
10:21 is the runtime stat chart glitched? It seems that no matter the percentage beat, it always lands in that crevice
@asagiai4965
@asagiai4965 Ай бұрын
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 Ай бұрын
The problem would only be partially solvable if you didn't know how much change you had in the beginning.
@asagiai4965
@asagiai4965 Ай бұрын
@@31redorange08 what does that even mean?
@31redorange08
@31redorange08 Ай бұрын
@@asagiai4965 How would you solve it without knowing how much change you had in the beginning?
@asagiai4965
@asagiai4965 Ай бұрын
@@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 Ай бұрын
@@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 Ай бұрын
Third, lol 😂
@c4rtel
@c4rtel Ай бұрын
first o_O
N-ary Tree Postorder Traversal - Leetcode 590 - Python
9:50
NeetCodeIO
Рет қаралды 6 М.
10 Math Concepts for Programmers
9:32
Fireship
Рет қаралды 1,9 МЛН
哈莉奎因怎么变骷髅了#小丑 #shorts
00:19
好人小丑
Рет қаралды 46 МЛН
Leetcode 1214. Two Sum BSTs (binary tree traversal)
5:08
Is Computer Science still worth it?
20:08
NeetCodeIO
Рет қаралды 111 М.
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 20 М.
Microservices Gone Wrong at DoorDash
17:22
NeetCodeIO
Рет қаралды 58 М.
Can You Generate Combinations? (LeetCode 77: Combinations)
7:25
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 316 М.
Creators of Devin AI are genius competitive programmers?
20:23
NeetCodeIO
Рет қаралды 183 М.
How Notion Cut Latency by 20%
19:00
NeetCodeIO
Рет қаралды 37 М.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 216 М.
The LeetCode Fallacy
6:08
NeetCode
Рет қаралды 510 М.