dimanche 27 avril 2014

Remove contiguous duplicate elements from an array list in Java (with panache)


Vote count:

0




So there lives an array list:



ArrayList<Character> charOutput = new ArrayList<Character>();


He eats chars, so he ends up like this:



[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, *, *, *, *, *, *, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]


But this is quite grotesque in our particular applicaiton. we want to trim him down, such that, finally, he looks like this:



[0,1,*,3,4]


So, how to do that?



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire