Programming Exercises

Create a component that finds the maximum depth of a hardcoded nested array and displays the depth.

Hard

Problem Statement

Create a component that finds the maximum depth of a hardcoded nested array and displays the depth.

Sample Input

[1, [2, [3, [4]]]]

Sample Output

Maximum Depth: 4

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
import React from "react"; const MaxDepth = () => { return ( <div> {/* Display the maximum depth */} </div> ); }; export default MaxDepth;
Log in or sign up to run or submit your code.Log inSign up
Input
[1, [2, [3, [4]]]]
Expected Output
Maximum Depth: 4