#C12763. Nested List Depth
Nested List Depth
Nested List Depth
Given a nested list represented in JSON format, your task is to compute the maximum depth of the nested structure. The depth is defined recursively as follows: if (A) is a list then (depth(A)=1+\max_{x\in A}(depth(x))) with the special condition that (depth([])=1), and if (A) is not a list then (depth(A)=0). For example, the depth of [1, [2, [3, [4, [5]]]]]
is 5, while the depth of 1
(a non-list value) is 0.
inputFormat
Input consists of a single line that contains a valid JSON representation of a nested list. The nested list may contain integers and other nested lists. Note that if the input is not a list (e.g. an integer), the depth is defined to be 0.
outputFormat
Output a single integer - the maximum depth of the given nested list.## sample
[1, [2, [3, [4, [5]]]]]
5