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

 

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

Write a method that accepts an original array called 'orig' and an array of numbers that need to be replaced in an array called 'replace'. Each time any of the numbers in 'replace' appears in 'orig', replace it with 'replaceVal'. It IS possible that 'replaceVal' will be the same value as one of the values in 'replace'. If that happens, use zero as the 'replaceVal'. Look at the test data for examples.


dec16_2019_HL_replace([500, 400, 750, 1200], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], -500) → [500, 400, 750, 1200]
dec16_2019_HL_replace([15, 20, 25, 3, 4, 5, 2], [25, 5, 2], 10000) → [15, 20, 10000, 3, 4, 10000, 10000]
dec16_2019_HL_replace([5, 8, 2, 1, 3, 7, 15, 9, 4, 22], [7, 1, 8], 50) → [5, 50, 2, 50, 3, 50, 15, 9, 4, 22]

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

public int[] dec16_2019_HL_replace(int[] orig, int[] replace, int replaceVal) { }

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: 290

Copyright Nick Parlante 2017 - privacy