Solve 2778. Sum of Squares of Special Elements

This commit is contained in:
Kiril Kovachev 2024-03-08 20:09:29 +00:00
parent 20757a2bf2
commit 59064dd981

View File

@ -0,0 +1,4 @@
class Solution:
def sumOfSquares(self, nums: List[int]) -> int:
n = len(nums)
return sum(x**2 for (i, x) in enumerate(nums) if n % (i+1) == 0)