Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SimplifyPath ¶
解法一
Example ¶
package main import ( "fmt" ) type question71 struct { para71 ans71 } // para 是参数 // one 代表第一个参数 type para71 struct { s string } // ans 是答案 // one 代表第一个答案 type ans71 struct { one string } func main() { qs := []question71{ { para71{"/.hidden"}, ans71{"/.hidden"}, }, { para71{"/..hidden"}, ans71{"/..hidden"}, }, { para71{"/abc/..."}, ans71{"/abc/..."}, }, { para71{"/home/"}, ans71{"/home"}, }, { para71{"/..."}, ans71{"/..."}, }, { para71{"/../"}, ans71{"/"}, }, { para71{"/home//foo/"}, ans71{"/home/foo"}, }, { para71{"/a/./b/../../c/"}, ans71{"/c"}, }, } for _, q := range qs { _, p := q.ans71, q.para71 fmt.Println(p, SimplifyPath(p.s)) } }
Output: {/.hidden} /.hidden {/..hidden} /..hidden {/abc/...} /abc/... {/home/} /home {/...} /... {/../} / {/home//foo/} /home/foo {/a/./b/../../c/} /c
func ValidParentheses ¶
Example ¶
package main import ( "fmt" ) type question20 struct { para20 ans20 } // para 是参数 // one 代表第一个参数 type para20 struct { one string } // ans 是答案 // one 代表第一个答案 type ans20 struct { one bool } func main() { qs := []question20{ { para20{"()[]{}"}, ans20{true}, }, { para20{"(]"}, ans20{false}, }, { para20{"({[]})"}, ans20{true}, }, { para20{"(){[({[]})]}"}, ans20{true}, }, { para20{"((([[[{{{"}, ans20{false}, }, { para20{"(())]]"}, ans20{false}, }, { para20{""}, ans20{true}, }, { para20{"["}, ans20{false}, }, } for _, q := range qs { _, p := q.ans20, q.para20 fmt.Println(p, ValidParentheses(p.one)) } }
Output: {()[]{}} true {(]} false {({[]})} true {(){[({[]})]}} true {((([[[{{{} false {(())]]} false {} true {[} false
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.