Count of Missing Numbers in a sorted array | Java program for the above approach ; Function that find the count of missing numbers in array a [ ] ; Calculate the count of missing numbers in the array ; Driver code
class GFG { public static void countMissingNum ( int [ ] a , int N ) { int count = a [ N - 1 ] - a [ 0 ] + 1 - N ; System . out . println ( count ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 10 , 20 , 40 } ; int N = arr . length ; countMissingNum ( arr , N ) ; } }