id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > test2024_01_22_APP1SLHL_reduceNumBy
prev  |  next  |  chance

Write a method that returns 'nums', but with each occurrence of 'toReduce' reduced by 'reduceBy'. For example, if 'nums' is {45,67,28,67,15} and 'toReduce' is 67 and 'reduceBy' is 7, you would return {45,60,28,60,15} (because each of the 67's was reduced by 7).


test2024_01_22_APP1SLHL_reduceNumBy([35, 35, 46, 72, 35, 8, 34, 36, 1], 35, 30) → [5, 5, 46, 72, 5, 8, 34, 36, 1]
test2024_01_22_APP1SLHL_reduceNumBy([], 17, 3) → []
test2024_01_22_APP1SLHL_reduceNumBy([80], 80, -2) → [82]

...Save, Compile, Run (ctrl-enter)

public int[] test2024_01_22_APP1SLHL_reduceNumBy(int[] nums, int toReduce, int reduceBy) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 240

Copyright Nick Parlante 2017 - privacy