jcq
This commit is contained in:
@@ -3,9 +3,7 @@ package jdshopapi
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
@@ -114,5 +112,37 @@ func TestFindStoreInfoByExtStoreId(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWIREHL(t *testing.T) {
|
||||
fmt.Println(fmt.Sprintf("%06v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(1000000)))
|
||||
fmt.Println(largeGroupPositions("abcdddeeeeaabbbcd"))
|
||||
}
|
||||
|
||||
func largeGroupPositions(s string) (result [][]int) {
|
||||
var (
|
||||
l = 0
|
||||
r = 1
|
||||
count int
|
||||
)
|
||||
fmt.Println(len(s))
|
||||
for {
|
||||
fmt.Println(l, r, count)
|
||||
if r == len(s) {
|
||||
if count > 1 {
|
||||
result = append(result, []int{l, r - 1})
|
||||
count = 0
|
||||
}
|
||||
break
|
||||
}
|
||||
if s[l] != s[r] {
|
||||
if count > 1 {
|
||||
result = append(result, []int{l, r - 1})
|
||||
count = 0
|
||||
}
|
||||
l = r
|
||||
r++
|
||||
count = 0
|
||||
} else {
|
||||
count++
|
||||
r++
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user