Count of Missing Numbers in a sorted array | C ++ 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; void countMissingNum ( int a [ ] , int N ) { int count = a [ N - 1 ] - a [ 0 ] + 1 - N ; cout << count << endl ; } int main ( ) { int arr [ ] = { 5 , 10 , 20 , 40 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countMissingNum ( arr , N ) ; return 0 ; }