Skip to content

Commit c50c8b0

Browse files
authored
Create 3940_Limit.py
1 parent a5cd487 commit c50c8b0

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

leetcode3/김민제/3940_Limit.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def limitOccurrences(self, nums: list[int], k: int) -> list[int]:
3+
new_array=[]
4+
for n in nums:
5+
if new_array.count(n)<k:
6+
new_array.append(n)
7+
return new_array
8+
9+
nums = [1,1,1,2,2,3]
10+
k = 2
11+
solution = Solution()
12+
print(solution.limitOccurrences(nums,k))

0 commit comments

Comments
 (0)