Skip to content

Latest commit

 

History

History

challenge-42

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Depth of a stringified binary tree

This problem was asked by Linkedin.

Description

You are given a binary tree in a peculiar string representation. Each node is written in the form (lr), where l corresponds to the left child and r corresponds to the right child.

If either l or r is null, it will be represented as a zero. Otherwise, it will be represented by a new (lr) pair.

Given this representation, determine the depth of the tree.

Example

Input: ((00)(00))
Output: 2