Maximum Distinct
Tina is stuck in a maze that from bird-eye view looks like a binary tree, i.e each checkpoint has two ways to choose from left and right. And each checkpoint is denoted by an integer. She is at the beginning and each path at the end has a door locked with a password. The password is the count of distinct integer she found at the checkpoints in the path. The door will only be unlocked if she chooses the path with the maximum number of distinct integers and enters their count. Help Tina find the correct path.
Note - You have to complete findDistinctCount() function, no need to implement the tree.
Input format
Root of the tree is passed to the findDistinctCount().
And the tree is constructed in level order format.
Output format
Return the maximum count of distinct integers present in a path from starting point to ending point.
Constraints
1
<=
N
<=
64
Example
Input
2 7 3 5 3 -1 2 -1 7 2 2 -1 -1 -1 3 -1 -1 -1 -1 -1 -1
Note - Level order traversal of input tree, where
−
1
represents null nodes.
Output
4
https://coding-platform-images.s3-ap-northeast-1.amazonaws.com/distinct-count.png
This is a photo of sample test case