Minimum number of consecutive sequences that can be formed in an array | Javascript program find the minimum number of consecutive sequences in an array ; Driver program ; function call to print required answer
function countSequences ( arr , n ) { let count = 1 ; arr . sort ( function ( a , b ) { return a - b } ) ; for ( let i = 0 ; i < n - 1 ; i ++ ) if ( arr [ i ] + 1 != arr [ i + 1 ] ) count ++ ; return count ; } let arr = [ 1 , 7 , 3 , 5 , 10 ] ; let n = arr . length ; document . write ( countSequences ( arr , n ) ) ;