BEAT 98% USERS|| 4 step in depth solution.
Intuition\n Describe your first thoughts on how to solve this problem. \nUSE SIMPLE GREEDY.\n\n# Approach\n Describe your approach to solving the problem. \nSte
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUSE SIMPLE GREEDY.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n**Steps:**\n\n1. **Initializing Variables:**\n   - `int five = 0`: Initializes a variable `five` to 0 to keep track of the number of $5 bills the stand has.\n   - `int ten = 0`: Initializes a variable `ten` to 0 to keep track of the number of $10 bills the stand has.\n\n2. **Processing Bills:**\n   - The `for` loop iterates through each bill (`bills[i]`) in the `bills` array.\n     - **Handling $5 Bills:**\n       - `if (bills[i] == 5)`: If the current bill is $5, the `five` counter is incremented.\n     - **Handling $10 Bills:**\n       - `else if (bills[i] == 10)`: If the current bill is $10, the code checks if there are enough $5 bills for change:\n         - `five--`: Decrements the `five` counter as a $5 bill is used for change.\n         - `ten++`: Increments the `ten` counter as a $10 bill is received.\n     - **Handling $20 Bills:**\n       - `else`: If the current bill is $20:\n         - **Prioritizing $10 Bills (if available):**\n           - `if (ten > 0)`: This checks if there\'s at least one $10 bill available.\n             - `ten--`: Decrements the `ten` counter as a $10 bill is used for change.\n             - `five--`: Decrements the `five` counter as a $5 bill is used for change (to make $15).\n         - **Using Only $5 Bills (if no $10 bills):**\n           - `else five = five - 3`: If there are no $10 bills, this subtracts 3 from `five`. This is a check to ensure the stand has enough $5 bills (at least 3) to provide change for a $20 bill.\n     - **Checking for Negative Values:**\n       - `if (ten < 0 || five < 0)`: After processing each bill, this condition checks if the `ten` or `five` counters become negative. A negative count signifies that the stand cannot provide sufficient change for previous transactions. In that case, the function returns `false`.\n\n3. **Returning the Result:**\n   - After iterating through all bills, if no negative counts were encountered, the loop completes, and the function returns `true`, indicating the stand can provide change for all customers.\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nThe complexity in O(N).\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n- The code uses constant extra space for the `five` and `ten` variables, leading to a space complexity of O(1).\n# Code\n```\nclass Solution {\n    public boolean lemonadeChange(int[] bills) {\n        int five=0;\n        int ten=0;\n        for(int i=0;i<bills.length;i++){\n            if(bills[i]==5){\n                five++;\n            }\n            else if(bills[i]==10){\n                five--;\n                ten++;\n            }\n            else{\n                if(ten>0){\n                    ten--;\n                    five--;\n                }\n                else five=five-3;\n                \n            }\n            if(ten<0 || five<0){\n                return false;\n            }\n        }\n        return true;\n    }\n}\n```
['Greedy', 'Java']