text: Find missing elements of a range | A hashing based C # program to find missing elements from an array ; Print all elements of range [ low , high ] that are not present in arr [ 0. . n - 1 ] ; Insert all elements of arr [ ] in set ; Traverse throught the range an print all missing elements ; Driver Code
code: using System ; using System . Collections . Generic ; class GFG { static void printMissing ( int [ ] arr , int n , int low , int high ) { HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { s . Add ( arr [ i ] ) ; } for ( int x = low ; x <= high ; x ++ ) if ( ! s . Contains ( x ) ) Console . Write ( x + " ▁ " ) ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 5 , 4 } ; int n = arr . Length ; int low = 1 , high = 10 ; printMissing ( arr , n , low , high ) ; } }