text: Check if the Xor of the frequency of all digits of a number N is zero or not | PHP implementation of the above approach ; creating a frequency array ; Finding the last digit of the number ; Dividing the number by 10 to eliminate last digit ; counting frequency of each digit ; checking if the xor of all frequency is zero or not ; Main Drive
code: < ? php function check ( $ s ) { $ freq = array_fill ( 0 , 10 , 0 ) ; while ( $ s != 0 ) { $ r = $ s % 10 ; $ s = ( int ) ( $ s / 10 ) ; $ freq [ $ r ] += 1 ; } $ xor = 0 ; for ( $ i = 0 ; $ i < 10 ; $ i ++ ) $ xor = $ xor ^ $ freq [ $ i ] ; if ( $ xor == 0 ) return true ; else return false ; } $ s = 122233 ; if ( check ( $ s ) ) print ( " Yes " ) ; else print ( " No " ) ; ? >