Skip to content

longest_uniform_substring_after_replacements in Sliding Windows incorrectly tracks highest_freq #85

Closed
@harvv

Description

@harvv

On page 97 in the book, an error is pointed out for an initial attempt at a solution, in that it doesn't track the highest_freq variable correctly as it runs and shrinks the window.
The solution given, which slides the window instead of shrinking in however, also has this problem if run with the parameters as:
longest_uniform_substring_after_replacements("aabcdeca", 2)

(whereas the book's test string is "aabcdcca")

Once the sliding window is on substring "abcde", the highest_freq value in the while loop is still 2 (which is incorrect).

(The overall function still seems to return the correct max_len value in this case, however.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions