Java Solution for Lemonade Change Problem
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem is essentially about managing change efficiently, given the constraints on 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem is essentially about managing change efficiently, given the constraints on the types of bills you can receive and the need to provide exact change. The challenge lies in ensuring that for every $10 or $20 bill received, you have the appropriate combination of $5 and $10 bills to provide the correct change. The greedy approach works here: always try to give the largest possible bills as change first, as this leaves you with smaller bills that are more flexible for future transactions\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1.\tTrack the bills: Use two counters, five and ten, to keep track of the number of $5 and $10 bills you have.\n2.\tProcess each bill:\n\t\u2022\tIf a customer pays with a $5 bill, simply increase the five counter.\n\t\u2022\tIf a customer pays with a $10 bill, check if you have at least one $5 bill to provide change. If you do, decrement the five counter and increase the ten counter. If not, return false because you can\u2019t provide the correct change.\n\t\u2022\tIf a customer pays with a $20 bill, try to give $15 in change. Preferably, this should be one $10 bill and one $5 bill (as this maximizes the number of $5 bills left). If you can\u2019t do that, check if you can give three $5 bills as change. If neither option is available, return false.\n3.\tReturn true if you successfully process all customers, meaning you could provide correct change every time.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n), where n is the length of the bills array. We process each bill exactly once, and all operations within the loop are O(1).\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1), as we only use a constant amount of additional space (five and ten counters).\n\n# Code\n```\nclass Solution {\n    public boolean lemonadeChange(int[] bills) {\n        int five = 0, ten = 0;\n        \n        for (int bill : bills) {\n            if (bill == 5) {\n                five++;\n            } else if (bill == 10) {\n                if (five == 0) {\n                    return false;\n                }\n                five--;\n                ten++;\n            } else if (bill == 20) {\n                if (ten > 0 && five > 0) {\n                    ten--;\n                    five--;\n                } else if (five >= 3) {\n                    five -= 3;\n                } else {\n                    return false;\n                }\n            }\n        }\n        \n        return true;\n    }\n}\n```
['Java']