Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions leetcode3/송주혜/4103. Remove Elements by Type and Color
Original file line number Diff line number Diff line change
@@ -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
Loading