Is this an existing problem?

Правка en1, от AkashCode77, 2024-02-18 04:48:48

So last day I participated in Leetcode Biweekly Contest 124. And as stupid as I am, I misread the first problem and made it harder. Link to the first problem.

The problem statement is as follows:


Given an array of integers called nums, you can perform the following operation while nums contains at least 2 elements:

  • Choose the first two elements of nums and delete them.
  • The score of the operation is the sum of the deleted elements.

Your task is to find the maximum number of operations that can be performed, such that all operations have the same score.

Return the maximum number of operations possible that satisfy the condition mentioned above.


I thought that before we delete the elements, we could arrange nums in any order we like. Now it makes me wonder is it a known problem with the added constraint that we can arrange the array in any order to maximize the sum? Moreover, I'm unable to think of a solution with the added constraint. I want to know the optimal way of solving this problem with the added constraint.

Thanks!

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский AkashCode77 2024-02-18 04:48:48 1390 Initial revision (published)