Number of Larger Elements on right side in a string | Javascript program to find counts of right greater characters for every character . ; Driver code
function printGreaterCount ( str ) { let len = str . length ; let right = new Array ( len ) ; right . fill ( 0 ) ; for ( let i = 0 ; i < len ; i ++ ) { for ( let j = i + 1 ; j < len ; j ++ ) { if ( str [ i ] . charCodeAt ( ) < str [ j ] . charCodeAt ( ) ) { right [ i ] ++ ; } } } for ( let i = 0 ; i < len ; i ++ ) { document . write ( right [ i ] + " " ) ; } } let str = " " ; printGreaterCount ( str ) ;