Question: Write a function in Java that will count the number of streaks of consecutive numbers in an array of integers. For example countStreaks ( [

Write a function in Java that will count the number of "streaks" of consecutive numbers in an array of integers.
For example
countStreaks([1,2,2,3,3,2,4]) should return 2 because there of the streak of 2's and the streak of 3's.
countStreaks([1,1,1,1]) should return 1 because there is a single streak of 41's.
countStreaks([1,2,1,2]) should return 0 because there is no streak of consecutive same numbers.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!