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

 

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

Write a method that accepts an array of integers, then returns an array of the same length, but with sequential duplicates removed. For each duplicate removed the resulting array will have an additional zero "padded" at the end of the array. So what is a sequential duplicate? That is when two or more of the same values appear adjacent to each other in the array. For example, in the array {4,7,7,7,13,13,21,50,-3,-3,-16} since there are three sevens in a row the second and third sevens are sequential duplicates. The is also one 13 that is a duplicate and one -3 that is a duplicate. Compare that to the array {5,7,10,5,2,10,7,2,33,15,15,33}. This array only has one sequential duplicate, which is the second 15. There are many other duplicates, but they are not SEQUENTIAL duplicates! So in the first array you would return {4,7,13,21,50,-3,-16,0,0,0,0} while in the second array you would return {5,7,10,5,2,10,7,2,33,15,33,0}


may_14_2019_APSLHL_removeDuplicates([3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) → [3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
may_14_2019_APSLHL_removeDuplicates([]) → []
may_14_2019_APSLHL_removeDuplicates([7]) → [7]

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

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