Update lexicographically smallest substring if the current count is equal to the maximum count
else if ( currCount = = maxCount ) { string temp = str . Substring ( i - K + 1 , K ) ; if ( string . Compare ( temp , res ) == - 1 ) res = temp ; } }