Leetcode 3091: Apply operations to make sum of array greater than or equal to k

Pierre-Marie Poitevin
2 min readMay 3, 2024

In this exercise with a very long title, we are given an array [1], then we can either:

  • Add 1 to a current value in the array
  • Copy take a value of the array and add it to the end of the array

We are trying to make it so that the sum of the array is greater or equal to k.

Algorithm to optimize sum

The first thing to notice is that copying a value and then add 1 to the value does…

--

--