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

 

abraskin@mbusd.org 2016_practice_set_6 > decompress
prev  |  next  |  chance

Information has been compressed as follows:
One array stores the values and a parallel array stores how many times that value is repeated in a row.
You must decompress the array by turning it into a single array with all the correct values in the correct order.
For example:

data[] = {1,2,3}
repeat[] = {1,4,2}
yields the array:
result[] = {1,2,2,2,2,3,3}

decompress([1, 2, 3], [1, 4, 2]) → [1, 2, 2, 2, 2, 3, 3]
decompress([1, 2, 3], [1, 1, 1]) → [1, 2, 3]
decompress([42], [1]) → [42]

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

public int[] decompress(int[] data, int[] repeat) { }

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

Copyright Nick Parlante 2017 - privacy