From a19dbd0458d81a80b568f6cbc35f287162872ffa Mon Sep 17 00:00:00 2001 From: zzu <90972641+Zuhye@users.noreply.github.com> Date: Wed, 11 Nov 2026 21:25:46 +0900 Subject: [PATCH] 4103. Remove Elements by Type and Color --- .../4103. Remove Elements by Type and Color" | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 "leetcode3/\354\206\241\354\243\274\355\230\234/4103. Remove Elements by Type and Color" diff --git "a/leetcode3/\354\206\241\354\243\274\355\230\234/4103. Remove Elements by Type and Color" "b/leetcode3/\354\206\241\354\243\274\355\230\234/4103. Remove Elements by Type and Color" new file mode 100644 index 00000000..5627c8b3 --- /dev/null +++ "b/leetcode3/\354\206\241\354\243\274\355\230\234/4103. Remove Elements by Type and Color" @@ -0,0 +1,17 @@ +class Solution: + def canRemoveAll(self, types: list[int], colors: list[int], groupSize: list[int]) -> bool: + arr = [] # [type, color, count] + result = False + for i, v in zip(types, colors): + if arr and arr[-1][0] == i and arr[-1][1] == v: + arr[-1][2] += 1 + + else: + arr.append([i, v, 1]) + + if arr[-1][2] == groupSize[i]: + arr.pop() + + if not arr: + result = True + return result