Find all numbers in range [ 1 , N ] that are not present in given Array | C # program for above approach ; Function to find the missing numbers ; traverse the array arr [ ] ; Update ; Traverse the array arr [ ] ; If Num is not present ; Driver Code ; Given Input ; Function Call
using System ; using System . Collections . Generic ; class GFG { static void getMissingNumbers ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { arr [ Math . Abs ( arr [ i ] ) - 1 ] = - ( Math . Abs ( arr [ Math . Abs ( arr [ i ] ) - 1 ] ) ) ; } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] > 0 ) Console . Write ( i + 1 + " ▁ " ) ; } } public static void Main ( ) { int N = 5 ; int [ ] arr = { 5 , 5 , 4 , 4 , 2 } ; getMissingNumbers ( arr , N ) ; } }