Skip to content

Commit

Permalink
leetcode subarrays distinct element sum of squares
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatelmas committed Nov 14, 2023
1 parent 74e8c9b commit 51445b7
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from typing import List


class Solution:
def sumCounts(self, nums: List[int]) -> int:
s, l = 0, len(nums)
for i in range(1, l + 1):
for j in range(0, l - i + 1):
n = len(set(nums[j : j + i]))
s += n * n
return s

0 comments on commit 51445b7

Please sign in to comment.