Python dp with hash table
\nclass Solution:\n    def numFactoredBinaryTrees(self, arr: List[int]) -> int:\n        arr.sort()\n        ans = 0\n        dp = {}\n        for n in arr:\n  
```\nclass Solution:\n    def numFactoredBinaryTrees(self, arr: List[int]) -> int:\n        arr.sort()\n        ans = 0\n        dp = {}\n        for n in arr:\n            temp = 1\n            for k in dp.keys():\n                if n%k==0 and n//k in dp:\n                    temp+=dp[k]*dp[n//k]\n            ans+= temp\n            dp[n] = temp\n        return ans%(10**9+7)\n        \n```
['Dynamic Programming', 'Python', 'Python3']