The description of this question is confusing...


  • 3

    Given a string that consists of only uppercase English letters, you can replace any letter in the string with another letter at most k times. Find the length of a longest substring containing all repeating letters you can get after performing the above operations.

    The bold line above is confusing.

    Interpretation 1: Does it means to allow us replace every single letter for at most K times?
    Humm well it's not, if it is then I think just by mentioning 1 times is enough and there's no need to emphasis K times.

    interpretation 2: Does it means to allow us replace every unique letter for at most K times?
    This interpretation works for both example 1 and 2.
    Input:
    s = "ABAB", k = 2
    Output:
    4
    We change letter A in this string for 2 times/We can change letter B in this string for 2 times

    But when I was thinking how about the input is:
    s = "ACBABBE", k = 1
    Then I was thinking we can change letter C to B for once and change A to B for once and finally E to B for once to get "ABBBBBB", the output is 6.

    However I was wrong again...

    And after seeing other posts here, I finally realized that this question actually wants you to replace at most k letters in this string , that's it:)

    I strongly advice to avoid ambiguous definition/interpretation using broken english in question description.


  • 0
    G

    +1 please rewrite this so it isn't so ambiguous


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.