🚀 Explained Greedy Basic Solution || Easy ♻️|| Concise 🎗️|| 4 Langauge
Screenshot \uD83C\uDF89\n\n\n\n---\n\n# Intuition \uD83E\uDD14\n\n    Given Imforamtion -->\n\n    We have a array of bills consider as store of cash notes\n\n 
# Screenshot \uD83C\uDF89\n\n![860.png](https://assets.leetcode.com/users/images/0cffcafc-00cf-4180-867e-474c5abefb6f_1717062779.668169.png)\n\n---\n\n# Intuition \uD83E\uDD14\n\n    Given Imforamtion -->\n\n    We have a array of bills consider as store of cash notes\n\n    \n`Bills all Ith pos assign a customer who bring us bills[i] cash`\n\n1. `From each customer` we have to `take exactly 5 doller` \n\n2. `At start` We don\'t have any cash in hand `0 Doller in hand`\n\n---\n\n# Approach \uD83E\uDEE0\n\n    As we know rather we get customer with \n\n    5 Doller ->  Take it as it is\n\n    10 Doller  -> return 1 -- 5 Doller bill\n\n    20 Doller -> return 1 -- 5 Doller and 1 -- 10 Doller bill\n\n    20 Doller -> or return 3 -- 5 Doller bills\n\n---\n\n# Understand with code \uD83E\uDD70\n\n       There will be 6 steps \n\n    Step 1 -> Make variables five and ten\n\n    Step 2 -> Interate whole loop  \n\n    Step 3 -> check Ith customer bill \n\n            if bill = 5 -> Then add in five\n\n    Step 4 -> If bill = 10  \n\n            Check 5 if >= 1 then dec five by 1 and inc ten by 1\n\n            else return false\n\n    Step 5 -> If bill = 20 \n\n            Check 5 if >= 1 And 10 >= 1 \n                then dec five by 1 and ten by 1\n\n            Check 5 elseif >= 3 \n                then dec five by 3\n\n            Else return false\n    \n\n    Step 6 -> return true\n---\n\n\n\n# Complexity \u2603\uFE0F\n- Time complexity: $$O(n)$$ \u267B\uFE0F\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$ \uD83D\uDE80\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n---\n\n# Code \u2728\n\n\n``` JAVA []\nclass Solution {\n    public boolean lemonadeChange(int[] bills) {\n            int five = 0;\n            int ten = 0;\n\n            for(int bill : bills){\n                  // if we get 5$ \n                  if (bill == 5) {\n                        five++;\n                  } else if (bill == 10) { // If we get 10$ \n                        if (five >= 1) { // we have to return 5$ so we should have it first\n                              five--;\n                              ten++;\n                        } else {\n                              return false;\n                        }\n                  } else { // If we get 20$ \n                        if (five >= 1 && ten >= 1) { // We have to return 15$ so 1 -- 10$ and 1 -- 5$\n                              ten--;\n                              five--;\n                        } else if (five >= 3) { // OR we can return 3 -- 5% \n                              five -= 3;\n                        } else {\n                              return false;\n                        }\n                  }\n            }\n\n            return true;\n      }\n}\n```\n```JAVASCRIPT []\nvar lemonadeChange = function (bills) {\n    let five = 0;\n    let ten = 0;\n\n    for (const bill of bills) {\n        // if we get 5$ \n        if (bill == 5) {\n            five++;\n        } else if (bill == 10) { // If we get 10$ \n            if (five >= 1) { // we have to return 5$ so we should have it first\n                five--;\n                ten++;\n            } else {\n                return false;\n            }\n        } else { // If we get 20$ \n            if (five >= 1 && ten >= 1) { // We have to return 15$ so 1 -- 10$ and 1 -- 5$\n                ten--;\n                five--;\n            } else if (five >= 3) { // OR we can return 3-- 5% \n                five -= 3;\n            } else {\n                return false;\n            }\n        }\n    }\n\n    return true;\n};\n```\n```PYTHON []\nclass Solution:\n    def lemonadeChange(self, bills: List[int]) -> bool:\n        five = 0\n        ten = 0\n\n        for bill in bills:\n            # if we get 5$\n            if bill == 5:\n                five += 1\n\n            elif bill == 10:\n                if five >= 1:\n                    five -= 1\n                    ten += 1\n\n                else:\n                    return False\n\n            else:\n                if five >= 1 and ten >= 1:\n                    five -= 1\n                    ten -= 1\n\n                elif five >= 3:\n                    five -= 3\n\n                else:\n                    return False\n\n        return True\n\n```\n```c []\nbool lemonadeChange(int* bills, int billsSize) {\n    int five = 0;\n    int ten = 0;\n\n    for (int i = 0; i < billsSize; i++) {\n        // if we get 5$\n        if (bills[i] == 5) {\n            five++;\n        } else if (bills[i] == 10) { // If we get 10$\n            if (five >= 1) { // we have to return 5$ so we should have it first\n                five--;\n                ten++;\n            } else {\n                return false;\n            }\n        } else { // If we get 20$\n            if (five >= 1 &&\n                ten >= 1) { // We have to return 15$ so 1 -- 10$ and 1 -- 5$\n                ten--;\n                five--;\n            } else if (five >= 3) { // OR we can return 3-- 5%\n                five -= 3;\n            } else {\n                return false;\n            }\n        }\n    }\n\n    return true;\n}\n```\n
['Array', 'Greedy', 'C', 'Java', 'Python3', 'JavaScript']