🔥Explanations No One Will Give You🎓🧠Very Detailed Approach🎯🔥Extremely Simple And Effective🔥
Complexity\n- Time complexity:\nO{n}\n\n- Space complexity:\nO{1}\n\n# Code\n\nclass Solution {\npublic:\n    bool lemonadeChange(vector<int>& bills) {\n       
# Complexity\n- Time complexity:\nO{n}\n\n- Space complexity:\nO{1}\n\n# Code\n```\nclass Solution {\npublic:\n    bool lemonadeChange(vector<int>& bills) {\n        int n = bills.size();\n        int a = 0;\n        int b = 0;\n        int c = 0;\n        for (int i = 0; i < n; i++) {\n            if (bills[i] == 5) {\n                a++; // 8\n            }\n            if (bills[i] == 10) {\n                b++; // 1\n                if (a > 0) {\n                    a--;\n                }\n                else\n                {\n                    return false;\n                }\n            }\n            if (bills[i] == 20) {\n                c++;\n                if (a <= 0) {\n                    return false;\n                }\n\n                if (b <= 0) {\n                    if (a >= 3) {\n                        a=a-3;\n                    }\n                    else\n                    {\n                        return false;\n                    }\n                }\n                if(b>0)\n                {\n                    a--;\n                    b--;\n                }\n            }\n        }\n\n        return true;\n    }\n};\n```
['Array', 'Greedy', 'Python', 'C++', 'Java']