From 2867bb5c357a59437d622528135b7531d581d64c Mon Sep 17 00:00:00 2001 From: unknown <1326cy@gmail.com> Date: Tue, 11 Aug 2026 22:41:15 +0900 Subject: [PATCH 1/2] day13 --- .../3803. Count Residue Prefixes.py" | 16 +++++++++++++++ .../837. New 21 Game.py" | 20 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 "leetcode3/\353\202\250\355\232\250\354\240\225/3803. Count Residue Prefixes.py" create mode 100644 "leetcode3/\353\202\250\355\232\250\354\240\225/837. New 21 Game.py" diff --git "a/leetcode3/\353\202\250\355\232\250\354\240\225/3803. Count Residue Prefixes.py" "b/leetcode3/\353\202\250\355\232\250\354\240\225/3803. Count Residue Prefixes.py" new file mode 100644 index 00000000..6f6b6f9b --- /dev/null +++ "b/leetcode3/\353\202\250\355\232\250\354\240\225/3803. Count Residue Prefixes.py" @@ -0,0 +1,16 @@ +class Solution: + def residuePrefixes(self, s: str) -> int: + ans = 0 + check = set() + + for i, char in enumerate(s): + check.add(char) + + # 종류가 3가지 이상이 되면 더 계산할 필요 없음 + if len(check) >= 3: + break + + # 문제에서 원하는 조건 만족할 때마다 정답 개수 += 1 + if len(check) == (i + 1) % 3: + ans += 1 + return ans \ No newline at end of file diff --git "a/leetcode3/\353\202\250\355\232\250\354\240\225/837. New 21 Game.py" "b/leetcode3/\353\202\250\355\232\250\354\240\225/837. New 21 Game.py" new file mode 100644 index 00000000..d732a098 --- /dev/null +++ "b/leetcode3/\353\202\250\355\232\250\354\240\225/837. New 21 Game.py" @@ -0,0 +1,20 @@ +# 풀이 실패 +class Solution: + def new21Game(self, n: int, k: int, maxPts: int) -> float: + if k == 0 or n >= k + maxPtsL + return 1.0 + + dp = [0.0] * (n + 1) + dp[0] = 1.0 + window_sum = 1.0 + + for i in range(1, n+1): + dp[i] = window_sum / maxPts + + if i < k: + window_sum += dp[i] + + if i >= maxPts and (i - maxPts) < k: + window_sum -= dp[i - maxPts] + + return sum(dp[k:]) \ No newline at end of file From 5bdf39485a3c2d2fa3775bd40bbfb71cd052bc84 Mon Sep 17 00:00:00 2001 From: unknown <1326cy@gmail.com> Date: Tue, 11 Aug 2026 22:44:05 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EC=98=A4=ED=83=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\353\202\250\355\232\250\354\240\225/837. New 21 Game.py" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/leetcode3/\353\202\250\355\232\250\354\240\225/837. New 21 Game.py" "b/leetcode3/\353\202\250\355\232\250\354\240\225/837. New 21 Game.py" index d732a098..2e57a97e 100644 --- "a/leetcode3/\353\202\250\355\232\250\354\240\225/837. New 21 Game.py" +++ "b/leetcode3/\353\202\250\355\232\250\354\240\225/837. New 21 Game.py" @@ -1,7 +1,7 @@ # 풀이 실패 class Solution: def new21Game(self, n: int, k: int, maxPts: int) -> float: - if k == 0 or n >= k + maxPtsL + if k == 0 or n >= k + maxPts: return 1.0 dp = [0.0] * (n + 1)