Sum of Squares (Set 11)

Easy

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

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

Example 1

sumOfSquares()
Input
nums = [-14, -14, 23, -18, -15, 15, -23, -4, 6, -25, 8, 26, 14, 14, 1, -15, -14, 16, -24, 2, 15, 18, 11, -15, -17, -24, -13, -2, 20, 1, 16, -7, 26, 10, -1, -4, 29, 23, -22, -12, 23, 18]
Output
11574

Why

`sumOfSquares` returns `11574` for this input.

Example 2

sumOfSquares()
Input
nums = [29, -6, 29, -11, -15, 2, 26, 27, -4, 11, 7, 1, 23, -14, -3, -21, -19, -6, 1, 1, 29, 13, -3, -11, -21, 16, 29, -13, 5, 1, 9, 25, 23, 14, -3, 13, -21, 22, 12, 6, 29, -21, -4, -11]
Output
12240

Why

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