Skip to main content

Checkpoint: the sandwich count

Challenge on lesson: Checkpoint: the sandwich count

CHALLENGE
Difficulty: advanced+25 XP

A 'sandwich' is three consecutive elements where the first and third are equal but the middle differs (like 1,9,1). Count the sandwiches in the array (overlapping counts: 1,9,1,9,1 contains three). Implement process(int[] arr) (0 for fewer than three elements).

Back to lesson: Checkpoint: the sandwich count