EASY C++||O(N) time O(1) Space
Intuition\n Describe your first thoughts on how to solve this problem. \ncount 5 and 10 dollars bill\n# Approach\n Describe your approach to solving the problem
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\ncount 5 and 10 dollars bill\n# Approach\n<!-- Describe your approach to solving the problem. -->\nif(bill==5) c5++\nif(bill==10) and c5>0 c5--\nif(bill==20){\n    //Two choices\n    //1.    10 + 5\n    //2.    5 + 5 + 5\n}\nImportant Note:\nWe will prefer to give 10+5 instead of 5+5+5 because we gonna save 5 dollar for future 10 dollar bill customer\n\nexample:\n5|5|5|5|10|20|10\n\nif we give 5+5+5 to 20 then our answer will be wrong because we will left with 10 \n\nbut if we give 10+5 then we will have 5+5\n\nI hope you understood !!\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n# Code\n```\nclass Solution {\npublic:\n    bool lemonadeChange(vector<int>& bills) {\n        int c5 = 0, c10 = 0;\n        for (auto bill : bills) {\n            if (bill == 5)\n                c5++;\n            else if (bill == 10 && c5 >= 1) {\n                c10++;\n                c5--;\n            } else if (bill == 20 && c10 >= 1 && c5 >= 1) {\n                c10--;\n                c5--;\n            } else if (bill == 20 && c5 >= 3) {\n                c5 -= 3;\n            } else\n                return false;\n        }\n        return true;\n    }\n};\n```
['C++']