Skip to content

Day 357 #706

@vaskoz

Description

@vaskoz

Good morning! Here's your coding interview problem for today.

This problem was asked by LinkedIn.

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.

Here are a few examples:

  • A root node with no children: (00)
  • A root node with two children: ((00)(00))
  • An unbalanced tree with three consecutive left children: ((((00)0)0)0)

Given this representation, determine the depth of the tree.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions