+ 2
What is partitioning array?
I want to make code about partitioning array for the SL assignment but i don't understand what it mean, i already red the explanation but still don't Understand can anybody explain what it is?
1 ответ
+ 14
●Firstly, you have to divide array into two sub arrays arrays[ same element of original array, can't be present in both of two divided arrays].
For example :
[2, 5, 4, 7, 15, 20]
can be divided into subarrays [15, 7, 4] and [20, 5, 2]
// (15+7+4) - (20+5+2) = -1 , ie difference of 1
OR
can be divided into subarrays [15, 7, 2] and [20, 5, 4]
// (15+7+2) - (20+5+4) = -5 , ie diff. of 5
OR
can be divided into subarrays [15, 4] and [20, 5, 2, 7]
// (15+4) - (20+5+2+7) = -15 , ie diff. of 15
//you can make many such 2 sub arrays from array [2, 5, 4, 7, 15, 20].
● then you have to see, in which sub arrays the difference is coming minimum, that will be the solution.
in above example, [15, 7, 4] & [20, 5, 2] is the solution as these 2 sub arrays give minimum difference of 1.
Challenge link : https://www.sololearn.com/learn/5863/?ref=app