C# Solution for Lemonade Change Problem
Intuition\n Describe your first thoughts on how to solve this problem. \nThe idea behind this solution is to use a flexible data structure (a dictionary) to man
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe idea behind this solution is to use a flexible data structure (a dictionary) to manage the count of different bills. The problem can be simplified by focusing on how much change is needed and ensuring that we can always meet this requirement using the bills we have in hand. The dictionary allows us to dynamically manage and query the number of $5 and $10 bills available, making it easy to check if we can provide the correct change for each transaction.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1.\tDictionary to Track Bills:\n\t\u2022\tWe use a Dictionary<int, int> where the keys represent the bill denominations (5 and 10), and the values represent the number of each bill currently available.\n2.\tProcessing Each Transaction:\n\t\u2022\tIf the customer pays with a 5 bill, simply increase the count of 5 bills in the dictionary.\n\t\u2022\tIf the customer pays with a 10 bill, we check if there\u2019s a 5 bill available (needed to provide 5 as change). If yes, decrement the count of 5 bills and increment the count of 10 bills.\n\t\u2022\tIf the customer pays with a 20 bill, try to give change using one 10 bill and one 5 bill (this is preferred to preserve smaller bills). If that isn\u2019t possible, check if three 5 bills can be given as change. If neither is possible, return false.\n3.\tReturn true if you successfully provide change for all customers.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n): The solution iterates through the bills array once, performing constant-time operations for each transaction. Since dictionary operations (like lookup and update) are O(1), the overall time complexity is linear with respect to the number of customers.\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1): The space complexity is constant because the dictionary only stores two keys (for $5 and $10 bills), regardless of the input size. This small, fixed amount of additional space is used irrespective of the number of transactions.\n\n# Code\n```\npublic class Solution {\n    public bool LemonadeChange(int[] bills) {\n        // Dictionary to store the count of $5 and $10 bills\n        Dictionary<int, int> billCount = new Dictionary<int, int> {\n            {5, 0},\n            {10, 0}\n        };\n        \n        foreach (int bill in bills) {\n            if (bill == 5) {\n                billCount[5]++;\n            } else if (bill == 10) {\n                // To give $5 as change\n                if (billCount[5] > 0) {\n                    billCount[5]--;\n                    billCount[10]++;\n                } else {\n                    return false;\n                }\n            } else if (bill == 20) {\n                // Prefer to give $10 + $5 as change\n                if (billCount[10] > 0 && billCount[5] > 0) {\n                    billCount[10]--;\n                    billCount[5]--;\n                } \n                // Otherwise, give three $5 bills as change\n                else if (billCount[5] >= 3) {\n                    billCount[5] -= 3;\n                } else {\n                    return false;\n                }\n            }\n        }\n        \n        return true;\n    }\n}\n```
['C#']