samedi 2 octobre 2021

fastest way to ditrubute x to array of elements such that difference of pairs is minimum possible?

given an array of numbers and an integer x, distribute x such that the difference between any pairs is minimum possible.

eg arr = [4,2,0] and x = 10;

ans should be [6,5,5];

it is obligatory to use x.

Aucun commentaire:

Enregistrer un commentaire