Leetcode/python/2778_sum_of_squares_of_special_elements.py
2024-03-08 20:09:29 +00:00

5 lines
163 B
Python

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)