categories: computer science
Hello everyone,
Below you will find a video with a detailed explanation of the greedy coin change algorithm. Its operation, time complexity, and usefulness. Below you will also find ready-made code to copy if needed.
Code:
listaMonet = [1, 2, 5, 11]
cena = 40
monety = []
for i in range(len(listaMonet) - 1, -1, -1):
while cena - listaMonet[i] >= 0:
cena -= listaMonet[i]
monety.append(listaMonet[i])
for j in monety:
print(str(j) + " ", end=None)
Video:
Thank you for reading!
Read more