mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-24 19:04:32 +08:00
Merge pull request #60 from halfrost/code_quality_improvement
optimization code quality level from A to A+
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
package leetcode
|
||||
|
||||
func characterReplacement(s string, k int) int {
|
||||
res, left, right, counter, freq := 0, 0, 1, 0, make([]int, 26)
|
||||
for right = 0; right < len(s); right++ {
|
||||
res, left, counter, freq := 0, 0, 0, make([]int, 26)
|
||||
for right := 0; right < len(s); right++ {
|
||||
freq[s[right]-'A']++
|
||||
counter = max(counter, freq[s[right]-'A'])
|
||||
for right-left+1-counter > k {
|
||||
|
@ -27,27 +27,27 @@ func Test_Problem424(t *testing.T) {
|
||||
|
||||
qs := []question424{
|
||||
|
||||
question424{
|
||||
{
|
||||
para424{"AABABBA", 1},
|
||||
ans424{4},
|
||||
},
|
||||
|
||||
question424{
|
||||
{
|
||||
para424{"ABBB", 2},
|
||||
ans424{4},
|
||||
},
|
||||
|
||||
question424{
|
||||
{
|
||||
para424{"BAAA", 0},
|
||||
ans424{3},
|
||||
},
|
||||
|
||||
question424{
|
||||
{
|
||||
para424{"ABCDE", 1},
|
||||
ans424{2},
|
||||
},
|
||||
|
||||
question424{
|
||||
{
|
||||
para424{"BAAAB", 2},
|
||||
ans424{5},
|
||||
},
|
||||
|
Reference in New Issue
Block a user