LeetCode #: 1208
Difficulty: Medium
Topics: Array, sliding window.
First, we need to understand that this problem deals with the differences between the characters in s
and t
, rather than the actual characters.
To get the maximum length of substring with a cost less than or equal to maxCost
, we use the sliding window technique on the differences to get the maximum length.
Assume n
is the number of characters in s
.
Time complexity: O(n)
Space complexity: O(1)