If this character is not - 1 or - 2 then it means that this character occurred only once so find the min index of all characters that occur only once , that 's our first index
if ( fi [ i ] >= 0 ) res = min ( res , fi [ i ] ) ; }