Double Each Value (Set 9)

Easy

Given an array of integers nums, return a new array where every value has been multiplied by 2.

Double Each Value (Set 9) — the data. This set runs 4 cases: nums holds arrays of 35–48 items, with values from -59 to 70. The hidden cases are the largest of the set.

Example 1

doubleEach()
Input
nums = [-57, 6, -53, 53, -42, -57, -58, 27, 33, -39, 48, 49, -16, 37, -3, 13, -17, 38, 33, -36, 34, 8, 1, 64, 55, 31, -53, 53, -24, -13, -16, 15, 29, 0, -51, 35, 30, -57, -40, 53]
Output
[-114, 12, -106, 106, -84, -114, -116, 54, 66, -78, 96, 98, -32, 74, -6, 26, -34, 76, 66, -72, 68, 16, 2, 128, 110, 62, -106, 106, -48, -26, -32, 30, 58, 0, -102, 70, 60, -114, -80, 106]

Why

`doubleEach` returns `[-114, 12, -106, 106, -84, -114, -116, 54, 66, -78, 96, 98, -32, 74, -6, 26, -34, 76, 66, -72, 68, 16, 2, 128, 110, 62, -106, 106, -48, -26, -32, 30, 58, 0, -102, 70, 60, -114, -80, 106]` for this input.

Example 2

doubleEach()
Input
nums = [15, 13, -25, -26, -47, 29, 4, -52, -36, 32, 14, -59, 50, 27, 2, -36, 27, -44, 10, -8, 57, -43, 44, -25, -38, -14, -37, -20, 17, 12, -6, 33, -20, 5, -57]
Output
[30, 26, -50, -52, -94, 58, 8, -104, -72, 64, 28, -118, 100, 54, 4, -72, 54, -88, 20, -16, 114, -86, 88, -50, -76, -28, -74, -40, 34, 24, -12, 66, -40, 10, -114]

Why

`doubleEach` returns `[30, 26, -50, -52, -94, 58, 8, -104, -72, 64, 28, -118, 100, 54, 4, -72, 54, -88, 20, -16, 114, -86, 88, -50, -76, -28, -74, -40, 34, 24, -12, 66, -40, 10, -114]` for this input.
Constraints
0 <= nums.length <= 10^5
-10^4 <= nums[i] <= 10^4
Every case in this set must pass: the first two are visible on Run, the last two unlock on Submit.

Topics

Arrays

Implement doubleEach in the editor and return the answer — printing it is never graded.