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

 

tmhscs@gmail.com monroe > compress_colorArray
prev  |  next  |  chance

Given an array of colors in the format of R,G,B,R,G,B,R,G,B... compress it using run length encoding so that it is changed to repeat,R,G,B,repeat,R,G,B,... and return the compressed array.


compress_colorArray([0, 0, 0]) → [1, 0, 0, 0]
compress_colorArray([0, 0, 0, 0, 0, 0]) → [2, 0, 0, 0]
compress_colorArray([0, 0, 0, 1, 1, 1]) → [1, 0, 0, 0, 1, 1, 1, 1]

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

public int[] compress_colorArray(int[] colors) { }

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

Post-solution available

Copyright Nick Parlante 2017 - privacy