获得徽章 0
- #青训营 x 字节后端训练营#
func removeZeroSumSublists(head *ListNode) *ListNode {
dummy := &ListNode{Val: 0}
dummy.Next = head
seen := map[int]*ListNode{}
prefix := 0
for node := dummy; node != nil; node = node.Next {
prefix += node.Val
seen[prefix] = node
}
prefix = 0
for node := dummy; node != nil; node = node.Next {
prefix += node.Val
node.Next = seen[prefix].Next
}
return dummy.Next
}展开评论点赞 - #青训营 x 字节后端训练营#
package utils
import (
"fmt"
"time"
)
func Retry(tryTimes int, trySleepTime time.Duration, action func() error) error {
var err error
for i := 0; i < tryTimes; i++ {
err = action()
if err == nil {
return nil
}
time.Sleep(trySleepTime * time.Duration(2*i+1))
}
return fmt.Errorf("retry action timeout: %v", err)
}展开评论点赞 - #青训营 x 字节后端训练营#
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Authors of KubeArmor
package main
import (
"fmt"
"github.com/sethvargo/go-githubactions"
)
func main() {
action := githubactions.New()
oldAppName := action.GetInput("old-app-image-name")
if oldAppName == "" {
action.Fatalf("old-app-image-name cannot be empty")
}
newAppName := action.GetInput("new-app-image-name")
if newAppName == "" {
action.Fatalf("new-app-image-name cannot be empty")
}
filepath := action.GetInput("filepath")
fmt.Printf("oldAppName: %v, newAppName: %v, filepath: %v", oldAppName, newAppName, filepath)
}展开评论点赞 - #青训营 x 字节后端训练营#
// ClusterRetained represents the filter to select clusters.
type ClusterRetained struct {
// LabelSelector is a filter to select member clusters by labels.
// If non-nil and non-empty, only the clusters match this filter will be selected.
// +optional
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
// FieldSelector is a filter to select member clusters by fields.
// If non-nil and non-empty, only the clusters match this filter will be selected.
// +optional
FieldSelector *FieldSelector `json:"fieldSelector,omitempty"`
// ClusterNames is the list of clusters to be selected.
// +optional
ClusterNames []string `json:"clusterNames,omitempty"`
// ExcludedClusters is the list of clusters to be ignored.
// +optional
ExcludeClusters []string `json:"exclude,omitempty"`
}展开评论点赞