Problem statement

https://binarysearch.com/problems/Making-Change/

Solution

We can use greedy strategy here, starting from big coins.

Complexity

It is O(1) for time and space.

Code

class Solution:
    def solve(self, n):
        x = [25, 10, 5, 1]
        ans = 0
        for coin in x:
            ans += n//coin
            n %= coin
        return ans