Double Each Value (Set 11)

Easy

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

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

Example 1

doubleEach()
Input
nums = [50, -52, -28, 23, -31, 15, -36, -6, 45, 67, -13, 26, -60, 14, 52, -35, 39, 56, 34, -16, 23, -27, 30, 47, -16, 15, -27, 61, -41, -24, -6, -9, -7, -11, 9, 17, 68, 8, -60, 56, -44, -4, -28]
Output
[100, -104, -56, 46, -62, 30, -72, -12, 90, 134, -26, 52, -120, 28, 104, -70, 78, 112, 68, -32, 46, -54, 60, 94, -32, 30, -54, 122, -82, -48, -12, -18, -14, -22, 18, 34, 136, 16, -120, 112, -88, -8, -56]

Why

`doubleEach` returns `[100, -104, -56, 46, -62, 30, -72, -12, 90, 134, -26, 52, -120, 28, 104, -70, 78, 112, 68, -32, 46, -54, 60, 94, -32, 30, -54, 122, -82, -48, -12, -18, -14, -22, 18, 34, 136, 16, -120, 112, -88, -8, -56]` for this input.

Example 2

doubleEach()
Input
nums = [66, 20, 62, -26, -19, -42, 64, -45, 48, -24, -15, -52, -51, 43, -31, 50, 58, 46, -49, 51, 65, -35, 28, -9, -46, 4, 60, -19, -20, 31, 40, -32, 16, -60, 34, -22, 2, 32, -11, 5, 41, -45, 54, 43, 34, -8, -17, 21]
Output
[132, 40, 124, -52, -38, -84, 128, -90, 96, -48, -30, -104, -102, 86, -62, 100, 116, 92, -98, 102, 130, -70, 56, -18, -92, 8, 120, -38, -40, 62, 80, -64, 32, -120, 68, -44, 4, 64, -22, 10, 82, -90, 108, 86, 68, -16, -34, 42]

Why

`doubleEach` returns `[132, 40, 124, -52, -38, -84, 128, -90, 96, -48, -30, -104, -102, 86, -62, 100, 116, 92, -98, 102, 130, -70, 56, -18, -92, 8, 120, -38, -40, 62, 80, -64, 32, -120, 68, -44, 4, 64, -22, 10, 82, -90, 108, 86, 68, -16, -34, 42]` 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.