Check if all elements of a Circular Array can be made equal by increments of adjacent pairs | C # program to implement the above approach ; Function to check if all array elements can be made equal ; Stores the sum of even and odd array elements ; If index is odd ; Driver Code
using System ; class GFG { static bool checkEquall ( int [ ] arr , int N ) { int sumEven = 0 , sumOdd = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( i % 2 == 1 ) sumOdd += arr [ i ] ; else sumEven += arr [ i ] ; } if ( sumEven == sumOdd ) return true ; else return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 7 , 3 , 5 , 7 } ; int N = arr . Length ; if ( checkEquall ( arr , N ) ) Console . Write ( " YES " + " STRNEWLINE " ) ; else Console . Write ( " NO " + " STRNEWLINE " ) ; } }