java.lang.Object
g0801_0900.s0823_binary_trees_with_factors.Solution

public class Solution extends Object
823 - Binary Trees With Factors.<p>Medium</p> <p>Given an array of unique integers, <code>arr</code>, where each integer <code>arr[i]</code> is strictly greater than <code>1</code>.</p> <p>We make a binary tree using these integers, and each number may be used for any number of times. Each non-leaf node&rsquo;s value should be equal to the product of the values of its children.</p> <p>Return <em>the number of binary trees we can make</em>. The answer may be too large so return the answer <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> arr = [2,4]</p> <p><strong>Output:</strong> 3</p> <p><strong>Explanation:</strong> We can make these trees: <code>[2], [4], [4, 2, 2]</code></p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> arr = [2,4,5,10]</p> <p><strong>Output:</strong> 7</p> <p><strong>Explanation:</strong> We can make these trees: <code>[2], [4], [5], [10], [4, 2, 2], [10, 2, 5], [10, 5, 2]</code>.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= arr.length <= 1000</code></li> <li><code>2 <= arr[i] <= 10<sup>9</sup></code></li> <li>All the values of <code>arr</code> are <strong>unique</strong>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • numFactoredBinaryTrees

      public int numFactoredBinaryTrees(int[] arr)