count the B ( blue ) colour
for ( i = 0 ; i < len ; i ++ ) { if ( color [ i ] == ' B ' ) Blue_Count ++ ; } for ( i = 0 ; i < len ; i ++ ) { if ( color [ i ] == ' B ' ) Blue_Count -- ; if ( color [ i ] == ' R ' ) Red_Count ++ ; if ( color [ i ] == ' G ' ) result += Red_Count * Blue_Count ; } return result ; }