Sum of Squares (Set 12)

Easy

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

Sum of Squares (Set 12) — 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 = [-23, 27, 15, 5, 26, 29, -22, 14, -4, 10, 8, -1, -12, 3, 26, -24, 0, -6, -2, 0, 30, 16, -16, -13, -4, -14, 1, -18, 14, 21, 4, -1, 27, 4, 24, 17, 14, 3, 8, 1, 1, 15, 24, -4, -13, -16, -25, -20]
Output
12251

Why

`sumOfSquares` returns `12251` for this input.

Example 2

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

Why

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