Ctrl K

Boost the Smallest

Easy
You are given an integer array values and two integers, rounds and factor. Play rounds rounds. In each round, find the smallest number in the array and multiply it by factor, writing the result back in the same place. If the smallest value occurs more than once, pick the leftmost occurrence. Return the array after all the rounds.
Example 1
values=[3, 1, 4, 1], rounds=3, factor=3 → [9, 3, 4, 3]

Round 1: the minimum 1 sits at positions 1 and 3, take the left one: [3, 3, 4, 1]. Round 2: the minimum 1 is at position 3: [3, 3, 4, 3]. Round 3: the minimum is 3, the leftmost one is at position 0: [9, 3, 4, 3].

Example 2
values=[7, 2], rounds=2, factor=1 → [7, 2]

A factor of 1 changes nothing, so the array stays the same.

Example 3
values=[5], rounds=4, factor=2 → [80]
Constraints
  • 1 ≤ values.length ≤ 100
  • 1 ≤ values[i] ≤ 100
  • 1 ≤ rounds ≤ 10
  • 1 ≤ factor ≤ 5
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsOdd Counters After the Presses EasyClearing the Stacks Evenly EasyPeel Off the Row Maximums EasyRemainder-One Whiteboard EasyShrink the Tallest Pile Easy
loading Python…
Input
values=[3, 1, 4, 1], rounds=3, factor=3
Expected
[9, 3, 4, 3]

Run checks the first 3 tests in your browser. Submit checks all 100 tests on the server, hidden ones included.