Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Geraud KAMENI
Correct solution

Geraud KAMENI

Jul 5, 2024

#The solution provide is incorrect, do not calculate max_lenght in invalid windows, add else condition # Current window size is from window_start to window_end, overall we have a letter             # which is repeating 'max_repeat_letter_count' times, this means we can have a window             # which has one letter repeating 'max_repeat_letter_count' times and the remaining             # letters we should replace. If the remaining letters are more than 'k', it is the             # time to shrink the window as we are not allowed to replace more than 'k' letters             if (window_end - window_start + 1 - max_repeat_letter_count) > k:                 left_char = str1[window_start]                 frequency_map[left_char] -= 1                 window_start += 1 else:            max_length = max(max_length, window_end - window_start + 1)

0

0

Comments
Comments

On this page