There was an error while loading. Please reload this page.
1 parent a5cd487 commit c50c8b0Copy full SHA for c50c8b0
1 file changed
leetcode3/김민제/3940_Limit.py
@@ -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