EASY TO UNDERSTAND JAVA SOLUTION BEATING 94.52% in 2ms 
Complexity
Time complexity: O(n)

Space complexity: O(1)
Code
![image.png](https://assets.leetcode.com/users/images/f9f63f2d-9701-4e15-aeb5-eac0ce73a02a_1737205215.904064.png)


# Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public boolean lemonadeChange(int[] bills) {
        int n=bills.length;
        int five=0,ten=0,twenty=0;
        for(int i=0;i<n;i++){
            if(bills[i]==5){
                five+=1;
            }
            if(bills[i]==10){
                ten+=1;
                if(five>0){
                    five-=1;
                }else{
                    return false;
                }
            }
            if(bills[i]==20){
                twenty+=1;
                if(five>=1 && ten>=1){
                    five-=1;
                    ten-=1;
                }else if(five>=3){
                    five-=3;
                }else{
                    return false;
                }
            }
        }
        return true;
    }
}
```
['Array', 'Greedy', 'Java']