Easy java Solution Using HashMap || Faster than 77.87%
Please Upvote if  you like this approach\n\n\nclass Solution {\n    public int numFactoredBinaryTrees(int[] arr) {\n        Arrays.sort(arr);\n        int mod =
**Please Upvote if  you like this approach**\n\n```\nclass Solution {\n    public int numFactoredBinaryTrees(int[] arr) {\n        Arrays.sort(arr);\n        int mod = 1000000007;\n        HashMap<Integer,Long>map = new HashMap<Integer,Long>();\n        long ans = 1;\n        map.put(arr[0],ans);\n        for(int i = 1; i<arr.length; i++)\n        {\n            long sum = 1;\n            for(int j = 0; j<i ;j++)\n            {\n                if(arr[i]%arr[j] == 0 && map.containsKey(arr[i]/arr[j]))\n                    sum = sum+(map.get(arr[i]/arr[j])*map.get(arr[j]));\n            }\n            map.put(arr[i],sum);\n            ans = ans+sum;\n        }\n        return (int)(ans%mod);\n    }\n}\n```
['Java']