✔️ Java solution: faster than 98.7% of other submissions
This Github repository, https://github.com/AnasImloul/Leetcode-solutions, have all the solutions I was looking for.\nIt is extremely beneficial to have every so
This Github repository, https://github.com/AnasImloul/Leetcode-solutions, have all the solutions I was looking for.\nIt is extremely beneficial to have every solution available in one place. I hope it is useful to you as well.\n```\nclass Solution {\n    public int sumOfFlooredPairs(int[] nums) {\n        Arrays.sort(nums);\n        int n=nums.length;\n        long cnt[]=new long[nums[n-1]+2];\n        for(int num:nums){\n            cnt[num+1]++;\n        }\n        for(int i=1;i<cnt.length;i++){\n            cnt[i]+=cnt[i-1];\n        }\n        long res=0;\n        long mod=1000000007;\n        long dp[]=new long[cnt.length];\n        for(int num:nums){\n            if(dp[num]!=0){\n                res=(res+dp[num])%mod;\n                continue;\n            }\n            long tot=0;\n            for(int j=num;j<cnt.length-1;j+=num){\n                tot=(tot+(j/num)*(cnt[Math.min(j+num-1,nums[n-1])+1]-cnt[j]))%mod;\n            }\n            dp[num]=tot;\n            res=(res+tot)%mod;\n        }\n        return (int)res;\n    }\n}\n\n```
['Java']