v9.1.1
Menu

Mini Parser

mediumPRONested Structures & IteratorsLinkedIn DSA

Given a string representing a nested integer list (e.g., [123,[456,[789]]]), parse it and return the flattened integers.

Output space-separated integers in order.

Example

Input
[123,[456,[789]]]
Output
123 456 789
Reasoning
  • The input string [123,[456,[789]]] is parsed as a nested list of integers.
  • The outermost list is processed first, yielding the integer 123.
  • The inner list [456,[789]] is then processed, yielding the integer 456 and another inner list [789].
  • The innermost list [789] is processed last, yielding the integer 789, resulting in the final output: 123 456 789.

Constraints

  • String is well-formed
  • Integers may be negative
  • Nesting depth <= 50

More from LinkedIn DSA

PRO

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test results

Sign in to run your code against the test cases.