码迷,mamicode.com
首页 > 其他好文 > 详细

[LeetCode] Mini Parser 迷你解析器

时间:2016-08-15 01:23:52      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

 

Given a nested list of integers represented as a string, implement a parser to deserialize it.

Each element is either an integer, or a list -- whose elements may also be integers or other lists.

Note: You may assume that the string is well-formed:

  • String is non-empty.
  • String does not contain white spaces.
  • String contains only digits 0-9[- ,].

 

Example 1:

Given s = "324",

You should return a NestedInteger object which contains a single integer 324.

 

Example 2:

Given s = "[123,[456,[789]]]",

Return a NestedInteger object containing a nested list with 2 elements:

1. An integer containing value 123.
2. A nested list containing two elements:
    i.  An integer containing value 456.
    ii. A nested list with one element:
         a. An integer containing value 789.

 

s

 

 

[LeetCode] Mini Parser 迷你解析器

标签:

原文地址:http://www.cnblogs.com/grandyang/p/5771434.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!