Sum of Squares (Set 9)

Easy

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

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

Example 1

sumOfSquares()
Input
nums = [-17, -21, -15, 24, 8, -7, 4, 18, 7, 14, 6, -24, 12, 14, 14, -12, 2, 19, 8, 21, 24, 27, 22, 25, -15, -14, -7, 3, -7, -4, 13, -23, -4, 30, 5, 26, 21, 28, 24, 28, 24, -19, -4, 13, -2, 4, -19, -5]
Output
13777

Why

`sumOfSquares` returns `13777` for this input.

Example 2

sumOfSquares()
Input
nums = [30, -25, 7, -1, 15, -18, 20, 23, 22, -15, 30, 22, -23, -10, 3, 2, -23, -20, -6, 12, 21, -6, -21, 29, 23, 18, -25, -7, -3, 23, 10, 30, 5, 30, 20, 29, 18, -12]
Output
14355

Why

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