Your question is O(n) String or Array Algorithm. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
DoorDash delivery status streams can contain short periods of inconsistent updates. Given a string of status codes, find the length of the longest contiguous segment that can be changed into one repeated status code using at most k replacements.
You may replace any character in the selected segment, and different positions may be replaced with different characters. Return only the maximum achievable length.
Implement longest_status_window(statuses, k), where statuses is a string and k is a nonnegative integer. Return an integer representing the longest contiguous substring that can be made uniform with at most k replacements.
def longest_status_window(statuses, k):