Sum of Squares (Set 7)

Easy

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

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

Example 1

sumOfSquares()
Input
nums = [-18, 21, 18, 26, 15, -20, -9, -13, 11, 6, 11, 8, -4, 13, 21, 12, 11, -23, -20, 11, -22, -20, 4, -18, 3, 23, -13, 11, -20, 8, 28, 1, 1, 10, 3]
Output
8334

Why

`sumOfSquares` returns `8334` for this input.

Example 2

sumOfSquares()
Input
nums = [-8, 18, -14, -20, 18, -12, 0, 6, 9, 2, -2, 17, 16, -3, 4, 16, -1, 11, 25, 26, -15, 0, -14, -10, -9, 0, -4, -6]
Output
4480

Why

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