From 59064dd98169ba86b46aa79dcaef38b1318dbb44 Mon Sep 17 00:00:00 2001 From: Kiril Kovachev Date: Fri, 8 Mar 2024 20:09:29 +0000 Subject: [PATCH] Solve 2778. Sum of Squares of Special Elements --- python/2778_sum_of_squares_of_special_elements.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 python/2778_sum_of_squares_of_special_elements.py diff --git a/python/2778_sum_of_squares_of_special_elements.py b/python/2778_sum_of_squares_of_special_elements.py new file mode 100644 index 0000000..82d0205 --- /dev/null +++ b/python/2778_sum_of_squares_of_special_elements.py @@ -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)