Tap here to switch tabs
Problem
Submissions

Problem: Binary Trees With Factors

med
30 min
Try to solve the Binary Trees With Factors problem.

Statement

Given an array of unique integers arr, you can construct binary trees using these integers as node values. Each integer in arr may be used any number of times.

A binary tree is considered valid if for every non leaf node, the value of the node is equal to the product of the values of its left and right children.

Return the number of distinct binary trees that can be created. Since the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq arr.length ≤1000\leq 1000

  • 2≤2 \leq arr[i] ≤109\leq 10^9

  • All the values of arr are unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Binary Trees With Factors

med
30 min
Try to solve the Binary Trees With Factors problem.

Statement

Given an array of unique integers arr, you can construct binary trees using these integers as node values. Each integer in arr may be used any number of times.

A binary tree is considered valid if for every non leaf node, the value of the node is equal to the product of the values of its left and right children.

Return the number of distinct binary trees that can be created. Since the answer may be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq arr.length ≤1000\leq 1000

  • 2≤2 \leq arr[i] ≤109\leq 10^9

  • All the values of arr are unique.