Sum of Squares (Set 5)

Easy

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

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

Example 1

sumOfSquares()
Input
nums = [-17, 5, -17, -20, 21, -6, -23, 15, 30, 19, 21, -14, 30, -3, 28, -9, 0, 13, -25, -6, 19, 21, 20, -23, -19, -25, -15, 8]
Output
9742

Why

`sumOfSquares` returns `9742` for this input.

Example 2

sumOfSquares()
Input
nums = [23, -2, -8, -19, -8, 0, 9, -22, 21, -16, 28, -15, 27, 4, -13, -22, -12, 28, 17, -15, 10, -3, 7, 26, 4, 25, -16]
Output
7864

Why

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