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

 

packN


Return an int[] of length n where the first n / m elements are set to sequential indexes where m divides the index with no remainder and the remaining elements are set to zero.


packN(10, 4) → [0, 4, 8, 0, 0, 0, 0, 0, 0, 0]
packN(20, 4) → [0, 4, 8, 12, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
packN(30, 4) → [0, 4, 8, 12, 16, 20, 24, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

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

public int[] packN(int n, int m) { }

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

Copyright Nick Parlante 2017 - privacy