Sum of Squares (Set 8)

Easy

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

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

Example 1

sumOfSquares()
Input
nums = [-1, -6, -16, 4, 28, 5, 2, -16, 10, -12, 20, -10, 25, 25, -19, 29, 29, -11, -19, 28, 10, 2, 11, -8, 13, 24, 12, -25, -18, -5, 24, 30, 10, 8, 18, -8, 17, -3, 26, -19]
Output
12196

Why

`sumOfSquares` returns `12196` for this input.

Example 2

sumOfSquares()
Input
nums = [20, -22, -8, -9, 13, 28, -9, 27, 19, -18, 22, 25, -15, 28, 6, 20, 8, 15, 15, 25, 4, -4, 22, 25, 13, 24, 4, -25, -15, -21, 5, -23, -9, 17, -2, 5, -8, -20, 28, -9, -24, 3, 27, 22]
Output
14443

Why

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