Back to October Back to Year 2026
EASY 11 Oct 2026 View on LeetCode

2778. Sum of Squares of Special Elements

</> Solution

/**
 * Problem: LeetCode 2778 - Sum of Squares of Special Elements
 * Difficulty: Easy
 * Language: Java
 * Author: CodeByTushu
 */
class Solution {
    public int sumOfSquares(int[] nums) {
        int n = nums.length;
        int sum = 0;

        for (int i = 1; i <= n; i++) {
            if (n % i == 0) {
                sum += nums[i - 1] * nums[i - 1];
            }
        }

        return sum;
    }
}

TIME COMPLEXITY

O(N) where N = nums.length ≤ 50

SPACE COMPLEXITY

O(1)

TOPICS

Array Enumeration Math Simulation