Back to problems Sign in to unlock
Leetcode
Medium
Arrays
Heaps
Sorting
Amazon
Final Array State After K Multiplication Operations II
Repeatedly multiply the smallest array element by a factor for k operations, then return the final array state.
Acceptance 0%
Problem Statement
Problem
You are given an integer array nums, an integer k, and an integer multiplier.
Repeat the following operation exactly k times:
- Choose the smallest value in
nums. - If there are multiple smallest values, choose the one with the smallest index.
- Replace that element with its value multiplied by
multiplier.
After all operations, return the final state of the array.
This problem asks you to efficiently simulate the process without re-scanning the entire array from scratch on every step.
Input Format
- An integer array
nums - An integer
k - An integer
multiplier
Output Format
- Return the array after performing the operation
ktimes.
Constraints
1 <= nums.lengthk >= 0multiplier >= 1- Values may grow during the process, so use a data structure that can repeatedly access the current minimum efficiently.
Examples
Sample cases returned by the problem API.
Example 1
Input
nums = [2,1,3], k = 3, multiplier = 2
Output
[4,4,3]
Explanation
Operations:
- Pick
1at index1->[2,2,3] - Pick
2at index0(tie with index1, smaller index wins) ->[4,2,3] - Pick
2at index1->[4,4,3]
Example 2
Input
nums = [1,2,1], k = 2, multiplier = 3
Output
[3,2,3]
Explanation
Operations:
- Pick
1at index0->[3,2,1] - Pick
1at index2->[3,2,3]
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.
Guided hints
Editorial and discussion links
Concept map and variants
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.