Use handshake lemma to count even subarrays ( Note that an even can be formed by two even or two odd )
$ result = $ result + ( int ) ( $ temp [ 0 ] * ( $ temp [ 0 ] - 1 ) / 2 ) ; $ result = $ result + ( int ) ( $ temp [ 1 ] * ( $ temp [ 1 ] - 1 ) / 2 ) ; return ( $ result ) ; }