Sum of Squares (Set 14)

Easy

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

Sum of Squares (Set 14) — 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 = [18, 1, -9, -7, 0, -14, 3, -7, -15, -9, -5, 25, -11, -18, -10, -10, -21, 17, 24, -2, -17, -25, 14, -1, 20, -15, -5, 24, -22, -8, -13, 18, -8, -4, -18, 24, -21, 13, 21, 23, 10, -23, -18, 25, 7, -22, -10, -15]
Output
11994

Why

`sumOfSquares` returns `11994` for this input.

Example 2

sumOfSquares()
Input
nums = [19, -21, 26, 0, -15, -7, 8, 10, -10, -2, -13, -20, 7, 20, 9, -9, 1, -14, -8, 0, 27, 14, 19, -1, 8, 12, -7, 1, -20, 12, 1, 22, -2, 3, 19, -12, 28, 21, 21, -8, 12, 18, 27, -17, 12, -11, 18, 19]
Output
10719

Why

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