Showing:
Handle Score
@Ibrahim Nash 5765
@akhayrutdinov 5111
@mb1973 4993
@Quandray 4944
@saiujwal13083 4506
@sanjay05 3762
@marius_valentin_dragoi 3516
@sushant_a 3459
@verma_ji 3341
@KshamaGupta 3318
Count the Number of Full Binary Trees
Medium Accuracy: 0.0% Submissions: 9 Points: 4

Given an array A[] of N integers, where each integer is greater than 1.The task is to find the number of Full binary tree from the given integers, such that each non leaf node value is the product of its children value.

Note: Each integer can be used multiple times in a full binary tree.

Example 1:
Input:
N = 4
A[] = {2, 3, 4, 6}

Output:
7
Explanation:
There are 7 full binary tree with
the given product property.
Four trees with single nodes
2  3  4  6
Three trees with three nodes
4   ,
/ \
2   2
6    ,
/ \
2   3

6
/ \
3   2

Example 2:
Input: N = 3
A[] = {2, 4, 5}

Output: 7
Explanation: There are 4 full binary tree
with the given product property.
Three trees with single nodes 2 4 5
One tree with three nodes
6
/ \
3   2

You don't need to read input or print anything. Your task is to complete the function numoffbt() which takes the array A[]and its size N as inputs and returns the number of Full binary tree.

Expected Time Complexity: O(N. Log(N))
Expected Auxiliary Space: O(N)

Constraints:
1 ≤ N ≤ 104
1 ≤ A[i] ≤ 104