Count the number of clumps in the given Array | Function to count the number of clumps in the given array arr [ ] ; Initialise count of clumps as 0 ; Traverse the arr [ ] ; Whenever a sequence of same value is encountered ; Return the count of clumps ; Driver Code ; length of the given array arr [ ] ; Function Call
function countClumps ( arr , N ) { let clumps = 0 ; for ( let i = 0 ; i < N - 1 ; i ++ ) { let flag = 0 ; while ( arr [ i ] == arr [ i + 1 ] ) { flag = 1 ; i ++ ; } if ( flag ) clumps ++ ; } return clumps ; } let arr = [ 13 , 15 , 66 , 66 , 66 , 37 , 37 , 8 , 8 , 11 , 11 ] ; let N = arr . length ; document . write ( countClumps ( arr , N ) ) ;