Skip to content

Instantly share code, notes, and snippets.

@foo4u
Created March 27, 2019 14:31
Show Gist options
  • Save foo4u/2370eb1f6bd3d7ca468d0d498e827c61 to your computer and use it in GitHub Desktop.
Save foo4u/2370eb1f6bd3d7ca468d0d498e827c61 to your computer and use it in GitHub Desktop.
Coding Bat
public int countClumps(int[] nums) {
int clumps = 0;
int last = -1;
int run = 0;
for(int i = 0; i< nums.length; i++) {
if (last == nums[i]) {
if(run < 1) {
clumps++;
}
run++;
} else {
run = 0;
}
last = nums[i];
}
return clumps;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment