✅✅ Just do with basic maths || Beats 100% || Easy Solution || C++ Solution
Approach
Start by checking if the first bill is greater than 5; if so, return false since change cannot be provided for the first customer.
Use two variables, f
# Approach
1. Start by checking if the first bill is greater than 5; if so, return `false` since change cannot be provided for the first customer.
2. Use two variables, `five` and `ten`, to track the count of $5 and $10 bills respectively.
3. Iterate through the `bills` array:
   - If the bill is 5, increment the `five` counter.
   - If the bill is 10:
     - Check if at least one 5 bill is available; if yes, decrement the `five` counter and increment the `ten` counter.
     - Otherwise, return `false` as no change can be provided.
   - If the bill is 20:
     - First, try to give one 10 and one 5 as change if possible.
     - If not, check if three 5 bills can be used as change.
     - If neither option is available, return `false`.
4. If all bills are processed successfully, return `true`.

# Intuition
The problem revolves around managing change efficiently. Prioritize using higher denomination bills ($10) for change first, as this conserves $5 bills, which are more versatile for future transactions. This greedy approach ensures the optimal handling of changes to maximize flexibility.

# Time Complexity
- **O(n)**: We iterate through the `bills` array once, where `n` is the number of customers.

# Space Complexity
- **O(1)**: Only two integer variables, `five` and `ten`, are used for tracking the count of 5 and 10 bills.

# Code
```cpp []
class Solution {
public:
    bool lemonadeChange(vector<int>& bills) {
        if(bills[0]>5) return false;
        int five=0,ten=0;
        for(int i:bills){
            if(i==5) five++;
            else if(i==10){
                if(five) five--,ten++;
                else return false;
            }
            else{
                if(five && ten) five--,ten--;
                else if(five>=3) five -= 3;
                else return false;
            }
        }
        return true;
    }
};
```
# Have a good day 😊 Upvote?
['Array', 'Greedy', 'C++']