Sum of Squares (Set 4)

Easy

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

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

Example 1

sumOfSquares()
Input
nums = [22, -7, 2, -18, -1, 26, -21, -19, -2, -10, 22, -10, -23, -6, 17, -17, 28, 23, -2, -11]
Output
5609

Why

`sumOfSquares` returns `5609` for this input.

Example 2

sumOfSquares()
Input
nums = [22, 15, -9, 18, 23, -16, -12, 22, -6, 23, 15, 12, -11, 8, 27, 15, -12, -1, 30, -21, -1, 20, 16, -4, -23, 0, -20, -13, -9]
Output
7938

Why

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