> ## Documentation Index
> Fetch the complete documentation index at: https://leetcode-py.wisl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> leetcode-py is a Python LeetCode practice environment generator with one CLI: lcpy. It is not a service or platform.
> Each problem is a directory under leetcode/ with README.md, solution.py, test_solution.py, helpers.py, and playground.ipynb. lcpy gen creates them from JSON templates bundled with the package.
> Examples are backed by tests; copy them verbatim.

# Final Array State After K Multiplication

> Tested Python solution for LeetCode 3264 with 18 pytest cases. Generate a practice environment with lcpy.

LeetCode 3264, [Easy](/catalog/easy). Topics: [Array](/catalog/topics/array), [Math](/catalog/topics/math), [Heap (Priority Queue)](/catalog/topics/heap-priority-queue), [Simulation](/catalog/topics/simulation). [View on LeetCode](https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-i/description/).

Generate this problem as a practice environment: tested reference solution, 18 [parametrized pytest cases](/practice/testing), and a playground notebook:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lcpy gen -n 3264   # by problem number
lcpy gen -s final_array_state_after_k_multiplication_operations_i   # by problem name
```

## Problem

You are given an integer array `nums`, an integer `k`, and an integer `multiplier`.

You need to perform `k` operations on `nums`. In each operation:

* Find the **minimum** value `x` in `nums`. If there are multiple occurrences of the minimum value, select the one that appears **first**.
* Replace the selected minimum value `x` with `x * multiplier`.

Return an integer array denoting the final state of `nums` after performing all `k` operations.

### Examples

```
Input: nums = [2,1,3,5,6], k = 5, multiplier = 2
Output: [8,4,6,5,6]
```

**Explanation:**

| Operation | Result |
| - | - |
| After operation 1 | \[2, 2, 3, 5, 6] |
| After operation 2 | \[4, 2, 3, 5, 6] |
| After operation 3 | \[4, 4, 3, 5, 6] |
| After operation 4 | \[4, 4, 6, 5, 6] |
| After operation 5 | \[8, 4, 6, 5, 6] |

```
Input: nums = [1,2], k = 3, multiplier = 4
Output: [16,8]
```

**Explanation:**

| Operation | Result |
| - | - |
| After operation 1 | \[4, 2] |
| After operation 2 | \[4, 8] |
| After operation 3 | \[16, 8] |

### Constraints

* 1 \<= nums.length \<= 100
* 1 \<= nums\[i] \<= 100
* 1 \<= k \<= 10
* 1 \<= multiplier \<= 5

## Solution

Reference implementation from [solution.py on GitHub](https://github.com/wislertt/leetcode-py/blob/main/leetcode/final_array_state_after_k_multiplication_operations_i/solution.py), full suite in [test\_solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/final_array_state_after_k_multiplication_operations_i/test_solution.py):

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import heapq


class Solution:
    # Time: O(n + k * log n)
    # Space: O(n)
    def get_final_state(self, nums: list[int], k: int, multiplier: int) -> list[int]:
        heap = [(value, index) for index, value in enumerate(nums)]
        heapq.heapify(heap)
        for _ in range(k):
            value, index = heapq.heappop(heap)
            heapq.heappush(heap, (value * multiplier, index))
        result = [0] * len(nums)
        while heap:
            value, index = heapq.heappop(heap)
            result[index] = value
        return result
```

## Complexity

| Time | Space |
| - | - |
| O(n + k \* log n) | O(n) |

## Tags

[NeetCode All](/catalog/neetcode).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.