Sum of Squares (Set 10)

Easy

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

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

Example 1

sumOfSquares()
Input
nums = [8, 16, -19, -23, -25, -19, 25, 0, -22, 0, 14, -16, -2, 7, -24, 24, 16, -21, 4, 20, 28, 27, -12, 18, 17, 13, 5, 26, -24, 19, 21, -15, -7, -6, -2, 14, -13, -6]
Output
11308

Why

`sumOfSquares` returns `11308` for this input.

Example 2

sumOfSquares()
Input
nums = [26, 17, -9, 29, 13, -18, 1, 28, 3, 8, 28, 16, 7, -16, -20, -25, 17, -13, -11, 21, 27, 5, 8, -4, 14, 19, -15, 22, 29, 19, 13, -20, -16, -4, 9, 5, -19, 17, -21, 29, 23, -21]
Output
13779

Why

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