From 5fe998f59d5d015d733631f201f278202d5ea4ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=97=BC=ED=98=9C=EC=A0=95?= <122238744+cyzlcyzl@users.noreply.github.com> Date: Tue, 22 Sep 2026 22:40:10 +0900 Subject: [PATCH] Create 860. Lemonade Change.java --- .../860. Lemonade Change.java" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "leetcode3/\354\227\274\355\230\234\354\240\225/860. Lemonade Change.java" diff --git "a/leetcode3/\354\227\274\355\230\234\354\240\225/860. Lemonade Change.java" "b/leetcode3/\354\227\274\355\230\234\354\240\225/860. Lemonade Change.java" new file mode 100644 index 00000000..cbe4d63d --- /dev/null +++ "b/leetcode3/\354\227\274\355\230\234\354\240\225/860. Lemonade Change.java" @@ -0,0 +1,33 @@ +// O(n) + +class Solution { + public boolean lemonadeChange(int[] bills) { + int balance_5 = 0; + int balance_10 = 0; + + for (int bill : bills) { + int change = bill - 5; + if (change == 0) { + balance_5++; + continue; + } + + if (change == 5) { + if (balance_5 < 1) return false; + balance_5--; + balance_10++; + } else if (change == 15) { + if (balance_5 >= 1 && balance_10 >= 1) { + balance_5--; + balance_10--; + } else if (balance_5 >= 3) { + balance_5 = balance_5 - 3; + } else { + return false; + } + + } + } + return true; + } +}