i want an idea | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

i want an idea

if there is a array, consider 1, 2 ,4, 5, 6 and there is a value 7...u have to find how many ways u will get 7,,here (1,6),(2,5),(1,2,4)...... array can be of any size ....

17th Jul 2017, 6:25 PM
Somnath Ghosh
Somnath Ghosh - avatar
1 Réponse
+ 1
Arrange the array in ascending or descending order then take the biggest number among them, add the next element. If there sum is greater than the value then next element if there sum is less than the value then add another element, if sum is equal print those numbers. Continue the process with the next big number and so on.
17th Jul 2017, 7:08 PM
G.S.N.V. Suraj
G.S.N.V. Suraj - avatar