[leet_code] Weekly Contest 193 (Running Sum of 1d Array, Least Number of Unique Integers after K Removals) with python3
26 Jun 2020
Reading time ~1 minute
1480. Running Sum of 1d Array
문제 : https://leetcode.com/contest/weekly-contest-193/problems/running-sum-of-1d-array/
class Solution:
def runningSum(self, nums: List[int]) -> List[int]:
return [sum(nums[:i+1]) for i in range(0,len(nums))]
1481. Least Number of Unique Integers after K Removals
문제 : https://leetcode.com/contest/weekly-contest-193/problems/least-number-of-unique-integers-after-k-removals/
class Solution:
def findLeastNumOfUniqueInts(self, arr: List[int], k: int) -> int:
v = sorted(collections.Counter(arr).values(), reverse = True)
while v and k>=v[-1]: k -= v.pop()
return len(v)