• 18

    No offense but this problem seriously needs some more explanation and grammar check. I want to add a few clarification as follows so it saves you some time:

    1. the add() method adds a NestedInteger object to the caller. e.g.:
      outer = NestedInteger() # []
      nested = NestedInteger(5)
      outer2 = nested
      outer.add(nested) # outer is now [5]
      outer2.add(outer) # outer2 is now [5, [5]]

    "Set this NestedInteger to hold a nested list and adds a nested integer elem to it." cannot be more vague.

    1. '-' means negative. It's not a delimiter.

    2. For test cases like "324" you need to return something like NestedInteger(324) not "[324]".

    3. A list cannot have multiple consecutive integers. e.g. "321, 231" is invalid. I guess it's for difficulty purposes.

  • 0

    @zchen39 great issues raised! the question is definitely in need of more example cases.

  • 0

    I have just the same confusion, thank you for the clarification!

  • 0

    Thank you. I've been confused to use NestedInteger.setInteger to implement outer.add(nested) # outer is now [5].

    It seems setInteger is really a useless function and cause vague.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.