text: Check if the Xor of the frequency of all digits of a number N is zero or not | Javascript 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 ; Driver function
code: function check ( s ) { let freq = new Array ( 10 ) . fill ( 0 ) , r ; while ( s != 0 ) { r = s % 10 ; s = parseInt ( s / 10 ) ; freq [ r ] += 1 ; } let xor__ = 0 ; for ( let i = 0 ; i < 10 ; i ++ ) { xor__ = xor__ ^ freq [ i ] ; if ( xor__ == 0 ) return true ; else return false ; } } let s = 122233 ; if ( check ( s ) ) document . write ( " " ) ; else document . write ( " " ) ;