Python/Python3 solution BruteForce & Optimized solution using Dictionary
Brute Foce Solution(Time Limit Exceeded)\n\nThis solution will work if the length of the elements in the testcase is <50000(5 * 10^4).\nIf it exceeds 50000 it w
**Brute Foce Solution(Time Limit Exceeded)**\n\nThis solution will work if the length of the elements in the testcase is <50000(5 * 10^4).\nIf it exceeds 50000 it will throw TLE error.\n**Code:**\n```\nclass Solution:\n    def sumOfFlooredPairs(self, nums: List[int]) -> int:\n        sumP = 0 #To store the value of Sum of floor values\n        for i in nums: #Traverse every element in nums\n            for j in nums: #Traverse every element in nums\n                sumP += (j//i) #Simply do floor division and add the number to sumP\n        return sumP % (10**9 +7)#return the sumof the pairs\n```\n\n**Optimized Solution**\n\nThe solution is built by using frequency of the prefix elements(freqency prefix sum).\n1. Take the frequency of the elements given in the nums and store ir in dictionary.\n2. After storing calculate the prefix frequency of the nums according to the frequency present in the dictionary.\n3. After computing prefix Frequency just calculate the sum of the floor division.\n* If you need to futher understanding the code kindly watch Part by Part Implementation. \n\n**Code:**\n```\nclass Solution:\n    def sumOfFlooredPairs(self, nums: List[int]) -> int:\n        maxi = max(nums) + 1\n        dic = {}\n        prefix=[0]*maxi\n        for i in nums:\n            if i in dic:\n                dic[i] += 1\n            else:\n                dic[i] = 1\n        #print(dic)\n        for i in range(1,maxi):\n            if i not in dic:\n                prefix[i] = prefix[i-1]\n            else:\n                prefix[i] = prefix[i-1]+dic[i]\n        #print(prefix,dic)\n        sumP = 0\n        for i in set(nums):\n            for j in range(i,maxi,i):\n                sumP += dic[i]*(prefix[-1]-prefix[j-1])\n\t\t\t\t#print(sumP,end = " ")\n        return sumP % (10**9 +7)\n```\n**Part by Part Implementation**\n```\n#Part - 1 : Calculating the frequency of the elements in nums to dictionary.\nclass Solution:\n    def sumOfFlooredPairs(self, nums: List[int]) -> int:\n        dic = {}\n        for i in nums:\n            if i in dic:\n                dic[i] += 1\n            else:\n                dic[i] = 1\n        print(dic)\n```\n**Output:\n{2: 1, 5: 1, 9: 1}**\n\n```\n#Part - 2 : Calculation of Prefix frequency according to the frequency of the nums in dictionary.\nclass Solution:\n    def sumOfFlooredPairs(self, nums: List[int]) -> int:\n        dic = {}\n        for i in nums:\n            if i in dic:\n                dic[i] += 1\n            else:\n                dic[i] = 1\n        #print(dic)\n        maxi = max(nums) + 1\n        prefix=[0]*maxi\n        for i in range(1,maxi):\n            if i not in dic:\n                prefix[i] = prefix[i-1]\n            else:\n                prefix[i] = prefix[i-1]+dic[i]\n        print(prefix)\n```\n**Output:\n[0, 0, 1, 1, 1, 2, 2, 2, 2, 3]**\n\n```\n#Part - 3 : Calculation of sum of floor division \nclass Solution:\n    def sumOfFlooredPairs(self, nums: List[int]) -> int:\n        maxi = max(nums) + 1\n        dic = {}\n        prefix=[0]*maxi\n        for i in nums:\n            if i in dic:\n                dic[i] += 1\n            else:\n                dic[i] = 1\n        #print(dic)\n        for i in range(1,maxi):\n            if i not in dic:\n                prefix[i] = prefix[i-1]\n            else:\n                prefix[i] = prefix[i-1]+dic[i]\n        #print(prefix,dic)\n        sumP = 0\n        for i in set(nums):\n            for j in range(i,maxi,i):\n                sumP += dic[i]*(prefix[-1]-prefix[j-1])\n                print(sumP,end = " ")\n```\n**Output:\n1 4 6 7 8 10**\n\n***We rise by lifting others***
['Counting', 'Python', 'Python3']