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

 

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

Write a method that returns the integer array that is passed in, except that every-other number has been replaced with a zero. So keep the first number, then replace the next one with zero, and keep alternating like that. There can be any number of numbers in the array. Look at the test data for examples.


sept26_2019_P1SLHL_replaceEveryOther([5, 17, -3, 18, 22, -64, -5]) → [5, 0, -3, 0, 22, 0, -5]
sept26_2019_P1SLHL_replaceEveryOther([4]) → [4]
sept26_2019_P1SLHL_replaceEveryOther([4, 2]) → [4, 0]

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

public int[] sept26_2019_P1SLHL_replaceEveryOther(int[] nums) { }

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