Minimum number of consecutive sequences that can be formed in an array | C # program find the minimum number of consecutive sequences in an array ; Driver program ; function call to print required answer
using System ; class GFG { static int countSequences ( int [ ] arr , int n ) { int count = 1 ; Array . Sort ( arr ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) if ( arr [ i ] + 1 != arr [ i + 1 ] ) count ++ ; return count ; } static public void Main ( String [ ] args ) { int [ ] arr = { 1 , 7 , 3 , 5 , 10 } ; int n = arr . Length ; Console . WriteLine ( countSequences ( arr , n ) ) ; } }