MCPcopy Create free account
hub / github.com/EndlessCheng/codeforces-go / CreatePath

Method CreatePath

leetcode/biweekly/7/b/b.go:20–36  ·  view source on GitHub ↗
(path string, value int)

Source from the content-addressed store, hash-verified

18}
19
20func (FileSystem) CreatePath(path string, value int) (ans bool) {
21 sp := strings.Split(path[1:], "/")
22 n := len(sp)
23 o := rt
24 for _, s := range sp[:n-1] {
25 if o.ch[s] == nil {
26 return
27 }
28 o = o.ch[s]
29 }
30 end := sp[n-1]
31 if o.ch[end] != nil {
32 return
33 }
34 o.ch[end] = &node{map[string]*node{}, value}
35 return true
36}
37
38func (FileSystem) Get(path string) (ans int) {
39 o := rt

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected