Class Solution
java.lang.Object
g1801_1900.s1862_sum_of_floored_pairs.Solution
1862 - Sum of Floored Pairs.<p>Hard</p>
<p>Given an integer array <code>nums</code>, return the sum of <code>floor(nums[i] / nums[j])</code> for all pairs of indices <code>0 <= i, j < nums.length</code> in the array. Since the answer may be too large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>
<p>The <code>floor()</code> function returns the integer part of the division.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [2,5,9]</p>
<p><strong>Output:</strong> 10</p>
<p><strong>Explanation:</strong></p>
<p>floor(2 / 5) = floor(2 / 9) = floor(5 / 9) = 0</p>
<p>floor(2 / 2) = floor(5 / 5) = floor(9 / 9) = 1</p>
<p>floor(5 / 2) = 2</p>
<p>floor(9 / 2) = 4</p>
<p>floor(9 / 5) = 1</p>
<p>We calculate the floor of the division for every pair of indices in the array then sum them up.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [7,7,7,7,7,7,7]</p>
<p><strong>Output:</strong> 49</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
<li><code>1 <= nums[i] <= 10<sup>5</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
sumOfFlooredPairs
public int sumOfFlooredPairs(int[] nums)
-