Deep Type Summary

JavaScript Medium 2 views
Back to Questions

Problem Description

You get one JSON value (can be nested). Traverse all nested values and count how many times each type appears: number, string, boolean, null, array, object. Print counts as JSON object.

Input Format

One line JSON value.

Output Format

One line JSON object.

Sample Test Case

Input:
{"a":[1,2,null],"b":{"x":true}}
Output:
{"number":2,"string":0,"boolean":1,"null":1,"array":1,"object":2}

Constraints

Total nodes up to 2e5.

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next