Closed
Description
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
Labels
No labels