题目:
题解:
func deserialize(s string) *NestedInteger {index := 0var dfs func() *NestedIntegerdfs = func() *NestedInteger {ni := &NestedInteger{}if s[index] == '[' {index++for s[index] != ']' {ni.Add(*dfs())if s[index] == ',' {index++}}index++return ni}negative := s[index] == '-'if negative {index++}num := 0for ; index < len(s) && unicode.IsDigit(rune(s[index])); index++ {num = num*10 + int(s[index]-'0')}if negative {num = -num}ni.SetInteger(num)return ni}return dfs()
}