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