Question: For each multiple of three in the given array, change all the values following it to be that multiple of three, until encountering another multiple
For each multiple of three in the given array, change all the values following it to be that multiple of three, until encountering another multiple of three. So {10, 3, 2, 4, 21, 5} yields {10, 3, 3, 3, 21, 21}.
extendThrees([10, 3, 2, 4, 21, 5]) [10, 3, 3, 3, 21, 21] extendThrees([1, 2, 3, 4, 5, 6, 7]) [1, 2, 3, 3, 3, 6, 6] extendThrees([3, 2, 4, 6, 5, 9, 8, 12]) [3, 3, 3, 6, 6, 9, 9, 12]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
