CPP program to find counts of right greater characters for every character .
#include <bits/stdc++.h> NEW_LINE using namespace std ; void printGreaterCount ( string str ) { int len = str . length ( ) , right [ len ] = { 0 } ; for ( int i = 0 ; i < len ; i ++ ) for ( int j = i + 1 ; j < len ; j ++ ) if ( str [ i ] < str [ j ] ) right [ i ] ++ ; for ( int i = 0 ; i < len ; i ++ ) cout << right [ i ] << " ▁ " ; }