Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5765 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4993 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1272 |

@bt8816103042 | 739 |

@rohitanand | 495 |

@codeantik | 479 |

@shalinibhataniya1097 | 472 |

@amrutakashikar2 | 464 |

@thealchemist627 | 456 |

@dalwainazism125 | 453 |

@shivanandp12345678910 | 453 |

@akashkale117 | 453 |

@SherlockHolmes3 | 447 |

Complete Leaderboard |

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

```
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

**Your Task: **

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 ≤ 10^{4}

1 ≤ A[i] ≤ 10^{4}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Count the Number of Full Binary Trees

...