← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Given a string that mixes digits, commas, and nested parentheses, write a function that parses it into a nested list structure. The input string represents a series of lists that may contain integers or other lists. A list is enclosed in balanced parentheses and its elements are comma-separated integers or sub-lists. Your task is to validate that every opening '(' has a matching closing ')' and, at the same time, build the corresponding nested list of integers (or sub-lists) that the string describes. Return the top-level list that contains all parsed elements. If brackets are unbalanced or mis-ordered, raise/return an error indication.