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
def countClumps ( arr , N ) : NEW_LINE INDENT clumps = 0 NEW_LINE i = 0 NEW_LINE while ( i < N - 1 ) : NEW_LINE INDENT flag = 0 NEW_LINE while ( i + 1 < N and arr [ i ] == arr [ i + 1 ] ) : NEW_LINE INDENT flag = 1 NEW_LINE i += 1 NEW_LINE DEDENT if ( flag ) : NEW_LINE INDENT clumps += 1 NEW_LINE DEDENT i += 1 NEW_LINE DEDENT return clumps NEW_LINE DEDENT arr = [ 13 , 15 , 66 , 66 , 66 , 37 , 37 , 8 , 8 , 11 , 11 ] NEW_LINE N = len ( arr ) NEW_LINE print ( countClumps ( arr , N ) ) NEW_LINE