0
Leetcode Problem 860. Lemonade Change
860. Lemonade Change
AI Mock Interview
Leetcode Solutions
Greedy Change Making for Lemonade Stand
Solution Idea
Algorithm Steps
Code Implementation
Complexity Analysis
Initialize two counters for
5
a
n
d
5 and
5
an
d
10 bills, both set to 0.
Loop through each bill in the
bills
array.
If the bill is
5
,
i
n
c
r
e
m
e
n
t
t
h
e
5, increment the
5
,
in
cre
m
e
n
tt
h
e
5 bill counter.
If the bill is
10
,
c
h
e
c
k
i
f
w
e
h
a
v
e
a
10, check if we have a
10
,
c
h
ec
ki
f
w
e
ha
v
e
a
5 bill to give as change. If yes, decrement the
5
b
i
l
l
c
o
u
n
t
e
r
a
n
d
i
n
c
r
e
m
e
n
t
t
h
e
5 bill counter and increment the
5
bi
ll
co
u
n
t
er
an
d
in
cre
m
e
n
tt
h
e
10 bill counter. If no, return
false
.
If the bill is
20
,
f
i
r
s
t
t
r
y
t
o
g
i
v
e
a
20, first try to give a
20
,
f
i
rs
tt
ry
t
o
g
i
v
e
a
10 and a
5
b
i
l
l
a
s
c
h
a
n
g
e
.
I
f
n
o
t
p
o
s
s
i
b
l
e
,
t
r
y
t
o
g
i
v
e
t
h
r
e
e
5 bill as change. If not possible, try to give three
5
bi
ll
a
sc
han
g
e
.
I
f
n
o
tp
oss
ib
l
e
,
t
ry
t
o
g
i
v
e
t
h
ree
5 bills. If neither is possible, return
false
.
If we can give change to all customers, return
true
.
Ask Question
Programming Language
Purpose:
General Question
Debug My Code
image/screenshot of info
(optional)
[+]
Full Screen
Loading...
Get Answer
Suggested Answer
Answer
Full Screen
Copy Answer Code
Loading...
Sign in with LinkedIn
Sign in with Github
OR
Sign in with Email link