Skip to main content

Find Deepest Maximum Element

MIDDLE

Find Deepest Maximum Element

Find the maximum element at the deepest level of a nested array.

Requirements:

  • Find the deepest level in nested arrays
  • Find maximum value at that level
  • Handle multiple levels of nesting

Example:

Input: [1, [2, [3, 4]], [5]]
Output: 4
Explanation: Deepest level is [3, 4], max is 4

Input: [1, 2, [3, [4, 5, [6]]]]
Output: 6

Examples:

Input 1:{"arr":[1,[2,[3,4]],[5]]}
Output 1:4
Input 2:{"arr":[1,2,[3,[4,5,[6]]]]}
Output 2:6

Loading editor...

Run your code to see results

Click the Run button above