|
| 1 | +3266\. Final Array State After K Multiplication Operations II |
| 2 | + |
| 3 | +Hard |
| 4 | + |
| 5 | +You are given an integer array `nums`, an integer `k`, and an integer `multiplier`. |
| 6 | + |
| 7 | +You need to perform `k` operations on `nums`. In each operation: |
| 8 | + |
| 9 | +* Find the **minimum** value `x` in `nums`. If there are multiple occurrences of the minimum value, select the one that appears **first**. |
| 10 | +* Replace the selected minimum value `x` with `x * multiplier`. |
| 11 | + |
| 12 | +After the `k` operations, apply **modulo** <code>10<sup>9</sup> + 7</code> to every value in `nums`. |
| 13 | + |
| 14 | +Return an integer array denoting the _final state_ of `nums` after performing all `k` operations and then applying the modulo. |
| 15 | + |
| 16 | +**Example 1:** |
| 17 | + |
| 18 | +**Input:** nums = [2,1,3,5,6], k = 5, multiplier = 2 |
| 19 | + |
| 20 | +**Output:** [8,4,6,5,6] |
| 21 | + |
| 22 | +**Explanation:** |
| 23 | + |
| 24 | +| Operation | Result | |
| 25 | +|-------------------------|------------------| |
| 26 | +| After operation 1 | [2, 2, 3, 5, 6] | |
| 27 | +| After operation 2 | [4, 2, 3, 5, 6] | |
| 28 | +| After operation 3 | [4, 4, 3, 5, 6] | |
| 29 | +| After operation 4 | [4, 4, 6, 5, 6] | |
| 30 | +| After operation 5 | [8, 4, 6, 5, 6] | |
| 31 | +| After applying modulo | [8, 4, 6, 5, 6] | |
| 32 | + |
| 33 | +**Example 2:** |
| 34 | + |
| 35 | +**Input:** nums = [100000,2000], k = 2, multiplier = 1000000 |
| 36 | + |
| 37 | +**Output:** [999999307,999999993] |
| 38 | + |
| 39 | +**Explanation:** |
| 40 | + |
| 41 | +| Operation | Result | |
| 42 | +|-------------------------|----------------------| |
| 43 | +| After operation 1 | [100000, 2000000000] | |
| 44 | +| After operation 2 | [100000000000, 2000000000] | |
| 45 | +| After applying modulo | [999999307, 999999993] | |
| 46 | + |
| 47 | +**Constraints:** |
| 48 | + |
| 49 | +* <code>1 <= nums.length <= 10<sup>4</sup></code> |
| 50 | +* <code>1 <= nums[i] <= 10<sup>9</sup></code> |
| 51 | +* <code>1 <= k <= 10<sup>9</sup></code> |
| 52 | +* <code>1 <= multiplier <= 10<sup>6</sup></code> |
0 commit comments