Tap here to switch tabs
Problem
Submissions

Problem: Apply Operations to Make Array Sum at Least k

Apply Operations to Make Array Sum at Least k starts with one array value. Increment an element or append its duplicate per operation, then return the fewest operations needed to reach the target sum.

Statement

You are given a positive integer k. You start with an array nums = [$1$].

In one operation, you can perform either of the following actions:

  1. Choose an element in nums and increment its value by 11.

  2. Select an element in nums and append a duplicate copy of it to nums.

Return the minimum number of operations required to make the sum of the elements in nums greater than or equal to k.

Constraints:

  • 1≤1 \leq k ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Apply Operations to Make Array Sum at Least k

Apply Operations to Make Array Sum at Least k starts with one array value. Increment an element or append its duplicate per operation, then return the fewest operations needed to reach the target sum.

Statement

You are given a positive integer k. You start with an array nums = [$1$].

In one operation, you can perform either of the following actions:

  1. Choose an element in nums and increment its value by 11.

  2. Select an element in nums and append a duplicate copy of it to nums.

Return the minimum number of operations required to make the sum of the elements in nums greater than or equal to k.

Constraints:

  • 1≤1 \leq k ≤105\leq 10^5