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

 

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

Given an integer array "a", compress the data using run-length encoding (RLE). RLE means that an array such as 1,1,1,2,2,2,2,2 could be compressed to 3,1,5,2 meaning that there are three 1's and then five 2's.


compress_integerArray([1, 2]) → [1, 1, 1, 2]
compress_integerArray([1, 1, 1, 2, 2, 2, 2, 2]) → [3, 1, 5, 2]
compress_integerArray([5, 5, 5, -1, -1, -1]) → [3, 5, 3, -1]

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

public int[] compress_integerArray(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

Post-solution available

Copyright Nick Parlante 2017 - privacy