Skip to main content

Practice ยท 2 of 5

Count adjacent repeats in a list

CHALLENGE
Difficulty: intermediate+25 XP

Count the positions i (from the second element on) where the element **equals its predecessor**. Use .equals โ€” these are Integer objects. Example: [1,1,2,2,2,3] โ†’ 3.

Back to lesson: Practice: Method mastery gauntlet