Find the two repeating elements in a given array | C # code for Find the two repeating elements in a given array ; Function to print repeating ; Driver program to test the above function
using System ; class GFG { static void printRepeating ( int [ ] arr , int size ) { int i ; Console . Write ( " The ▁ repeating ▁ elements ▁ are ▁ : ▁ " ) ; for ( i = 0 ; i < size ; i ++ ) { if ( arr [ Math . Abs ( arr [ i ] ) ] > 0 ) arr [ Math . Abs ( arr [ i ] ) ] = - arr [ Math . Abs ( arr [ i ] ) ] ; else Console . Write ( Math . Abs ( arr [ i ] ) + " ▁ " ) ; } } public static void Main ( ) { int [ ] arr = { 4 , 2 , 4 , 5 , 2 , 3 , 1 } ; int arr_size = arr . Length ; printRepeating ( arr , arr_size ) ; } }