aa
This commit is contained in:
@@ -226,7 +226,82 @@ func TestUpdateDeliveryPromise(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUploadImageNew(t *testing.T) {
|
||||
fmt.Println(int(utils.Str2Time("2021-03-09 23:59:59").Sub(utils.Str2Time("2021-03-07 00:00:00")).Hours()) / 24)
|
||||
s := "PLLPLA"
|
||||
fmt.Println(checkRecord(s))
|
||||
}
|
||||
|
||||
func checkRecord(s string) bool {
|
||||
countL := 0
|
||||
countA := 0
|
||||
for _, v := range s {
|
||||
if v == 'A' {
|
||||
countA++
|
||||
if countA > 1 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if v == 'L' {
|
||||
countL++
|
||||
if countL > 2 {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
countL = 0
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func sink(array []int, length int) {
|
||||
start := 0
|
||||
for {
|
||||
//2*n+1 可以画图就知道为什么了,是左边子节点
|
||||
next := 2*start + 1
|
||||
if next > length {
|
||||
break
|
||||
}
|
||||
if next+1 <= length && array[next+1] < array[next] {
|
||||
next++
|
||||
}
|
||||
|
||||
//上层小于下面,不用互换了
|
||||
if array[start] <= array[next] {
|
||||
break
|
||||
}
|
||||
//互换继续下沉
|
||||
array[start], array[next] = array[next], array[start]
|
||||
start = next
|
||||
}
|
||||
}
|
||||
|
||||
//堆
|
||||
//top k
|
||||
func topk(s []int, k, i int) {
|
||||
for {
|
||||
left := i*2 + 1
|
||||
right := i*2 + 2
|
||||
if i < 0 {
|
||||
break
|
||||
}
|
||||
if right == k {
|
||||
if s[i] < s[left] {
|
||||
s[i], s[left] = s[left], s[i]
|
||||
}
|
||||
} else {
|
||||
if s[i] < s[left] || s[i] < s[right] {
|
||||
if s[left] < s[right] {
|
||||
s[i], s[right] = s[right], s[i]
|
||||
} else {
|
||||
s[i], s[left] = s[left], s[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
if i-1 < 0 {
|
||||
break
|
||||
}
|
||||
i = (i - 1) / 2
|
||||
}
|
||||
fmt.Println("loop s", s)
|
||||
}
|
||||
|
||||
//给定一个包含正整数、加(+)、减(-)、乘(*)、除(/)的算数表达式(括号除外),计算其结果。
|
||||
|
||||
Reference in New Issue
Block a user