Skip to content

Latest commit

 

History

History
21 lines (11 loc) · 715 Bytes

File metadata and controls

21 lines (11 loc) · 715 Bytes

Get Equal Substrings Within Budget

LeetCode #: 1208

Difficulty: Medium

Topics: Array, sliding window.

Explanation

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.

Complexity Analysis

Assume n is the number of characters in s.

Time complexity: O(n)

Space complexity: O(1)