Minimum number of consecutive sequences that can be formed in an array | Python3 program find the minimum number of consecutive sequences in an array ; Driver program ; function call to print required answer
def countSequences ( arr , n ) : NEW_LINE INDENT count = 1 NEW_LINE arr . sort ( ) NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT if ( arr [ i ] + 1 != arr [ i + 1 ] ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT arr = [ 1 , 7 , 3 , 5 , 10 ] NEW_LINE n = len ( arr ) NEW_LINE print ( countSequences ( arr , n ) ) NEW_LINE DEDENT