Minimum removals to make array sum odd | C ++ implementation of the above approach ; Function to find minimum removals ; Count odd numbers ; If the counter is odd return 0 otherwise return 1 ; Driver Code
#include <iostream> NEW_LINE using namespace std ; int findCount ( int arr [ ] , int n ) { int countOdd = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 == 1 ) countOdd ++ ; if ( countOdd % 2 == 0 ) return 1 ; else return 0 ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 5 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findCount ( arr , n ) ; return 0 ; }