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