Leetcode/python/2778_sum_of_squares_of_special_elements.py

5 lines
163 B
Python
Raw Permalink Normal View History

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)