We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5346623 commit cb66bbfCopy full SHA for cb66bbf
longest-repeating-character-replacement/printjin-gmailcom.py
@@ -0,0 +1,14 @@
1
+class Solution:
2
+ def characterReplacement(self, s, k):
3
+ count = [0] * 26
4
+ left = 0
5
+ max_count = 0
6
+ res = 0
7
+ for right in range(len(s)):
8
+ count[ord(s[right]) - ord('A')] += 1
9
+ max_count = max(max_count, count[ord(s[right]) - ord('A')])
10
+ while (right - left + 1) - max_count > k:
11
+ count[ord(s[left]) - ord('A')] -= 1
12
+ left += 1
13
+ res = max(res, right - left + 1)
14
+ return res
0 commit comments