Python DP detailed explantion | dictionary | T/M: 91.4%/90.9% | easy to understand ^_^
1.sort the array in ascending order\n2.create a dictionary and initialize it\n3.loop through the data\n4.return sum of values\n\nTake this for example:\n\tarr =
1.sort the array in ascending order\n2.create a dictionary and initialize it\n3.loop through the data\n4.return sum of values\n\nTake this for example:\n\t`arr = [2, 4, 5, 10] `\n![image](https://assets.leetcode.com/users/images/6eaaaab7-d9bc-4384-bafb-5bba4ab8ac04_1660010194.973968.png)\n\nCode:\n```\nclass Solution:\n    def numFactoredBinaryTrees(self, arr: List[int]) -> int:\n        \n        arr.sort()\n        MOD = 10**9 + 7\n        \n        # create a dictionary and initialize\n        dp = {}\n        for n in arr:\n            dp[n] = 1\n            \n        # loop through each number\n        for i, n in enumerate(arr):\n            for j in range(i):\n                if not(n % arr[j]) and n // arr[j] in dp:\n                    dp[n] += dp[arr[j]] * dp[n//arr[j]]\n                    dp[n] %= MOD\n        \n        return sum(dp.values()) % MOD\n```\n**Please UPVOTE if you LIKE !!!**\n![image](https://assets.leetcode.com/users/images/c6a55e6b-4ada-4103-ba39-c7a2197aee9b_1660008862.3782873.png)\n
['Dynamic Programming', 'Python']