C++ | Simple 0 ms 5 lines solution beats 100% of the submitted solutions in runtime
IntuitionFind the indices that can divide the length of the array without any remainder and add the square of the elements at those positions in the array to th
# Intuition
Find the indices that can divide the length of the array without any remainder and add the square of the elements at those positions in the array to the sum.  

# Approach
Parse the indices till the mid of the length of the arrray since that will be the max divisor. Find the indices that are divisors of the length of the array and add the square of the elements at those indices to the sum.  

# Complexity
- Time complexity for `n` elements in the array: $$O(n)$$

- Space complexity for `n` elements in the array: $$O(1)$$

# Code
```cpp []
class Solution {
public:
    int sumOfSquares(vector<int>& nums) {
        const int n = nums.size();
        int sum_of_squares = 0;
        for (int i=1; i<=n/2; ++i)  sum_of_squares += (n % i == 0) ? nums[i-1] * nums[i-1] : 0;
        sum_of_squares += nums[n-1] * nums[n-1];

        return sum_of_squares;
    }
};
```
['C++']