728x90
https://leetcode.com/problems/find-the-distinct-difference-array/
class Solution:
def distinctDifferenceArray(self, nums: List[int]) -> List[int]:
result = []
for i in range(len(nums)):
result.append(len(set(nums[:i+1])) - len(set(nums[i+1:])))
return result
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 876. Middle of the Linked List (0) | 2024.03.07 |
---|---|
[Leetcode] 961. N-Repeated Element in Size 2N Array (0) | 2024.03.07 |
[Leetcode] 1207. Unique Number of Occurrences (0) | 2024.03.06 |
[Leetcode] 1941. Check if All Characters Have Equal Number of Occurrences (0) | 2024.03.05 |
[Leetcode] 1748. Sum of Unique Elements (0) | 2024.03.04 |