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