Sum of Squares (Set 13)

Easy

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

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

Example 1

sumOfSquares()
Input
nums = [-21, 12, 22, 4, -25, 4, -17, 15, -22, -19, -3, 3, 14, 8, 7, 4, -17, 27, -23, 3, -4, 27, 21, 28, 26, 8, 4, 29, 5, 24, -24, -14, 3, 29, 17, -17, 28, -18, 3, 7, -6, 27, -11, -11, 19, 17, 10, -12]
Output
14419

Why

`sumOfSquares` returns `14419` for this input.

Example 2

sumOfSquares()
Input
nums = [-17, 0, -13, 22, 30, 2, 7, 25, 9, 3, 8, 1, -19, 1, 24, -21, -23, 20, -22, -10, 25, 23, -13, -2, -24, 6, -23, 20, 16, -18, -3, -15, 14, 2, -8, 8, -9, -5, 3, -3, -3, 7, -2, 17, -1, -14, 15, -19]
Output
10835

Why

`sumOfSquares` returns `10835` 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.