Sum of Squares (Set 6)

Easy

Given an array of integers nums, return the sum of every value squared.

Sum of Squares (Set 6) — the data. This set runs 4 cases: nums holds arrays of 25–29 items, with values from -25 to 30. The hidden cases are the largest of the set.

Example 1

sumOfSquares()
Input
nums = [29, 23, 22, -14, 1, -16, 11, -16, 1, -4, 4, 6, 29, 16, -6, 23, -22, -9, 25, 22, 17, 15, 16, 12, 5, -4, 8, 26, 28]
Output
8568

Why

`sumOfSquares` returns `8568` for this input.

Example 2

sumOfSquares()
Input
nums = [1, 0, -11, 13, 18, -11, 17, 14, -18, 2, -9, 14, 17, 5, -5, -23, 12, 29, -24, -23, 2, -7, 26, 1, -17, 16]
Output
6059

Why

`sumOfSquares` returns `6059` for this input.
Constraints
0 <= nums.length <= 10^4
-100 <= nums[i] <= 100
Every case in this set must pass: the first two are visible on Run, the last two unlock on Submit.

Topics

ArraysMath

Implement sumOfSquares in the editor and return the answer — printing it is never graded.