Let,
min_dif=INT_MAX
1.Sort the N arrays A,B,C.
2.Find the minimum and maximum of A[0],B[0],C[0].
3.Take the difference between MAX-MIN values.
5.If the difference is less than min_dif then update min_dif and save all n
values.
6.Now increment the index of the array which contains
as per my understanding , you are increasing the minimum value so that it
reaches closer to the maximum others that we are not moving right now . Why
are you not moving the maximum instead ?
basically i need the reason why you are doing so ..
thanks
--mac;
On Thu, Aug 18, 2011 at 12:08 PM,
If we move the maximum then difference will get larger but our aim is to
minimize the difference.
Thanks Regards,
Anantha Krishnan
On Thu, Aug 18, 2011 at 1:01 PM, MAC macatad...@gmail.com wrote:
as per my understanding , you are increasing the minimum value so that it
reaches closer to the
in the example below , answer shd be 0 , . by your apraoch this is not
commig
10,25,35
10,25,30
5 ,6,25,30
On Thu, Aug 18, 2011 at 1:08 PM, Anantha Krishnan
ananthakrishnan@gmail.com wrote:
If we move the maximum then difference will get larger but our aim is to
minimize the
Yes with my approach answer will be 0.
Please check here http://ideone.com/Q4ivj.
Thanks Regards,
Anantha Krishnan
On Thu, Aug 18, 2011 at 1:33 PM, MAC macatad...@gmail.com wrote:
in the example below , answer shd be 0 , . by your apraoch this is not
commig
10,25,35
10,25,30
5
Hey Mac, Coded it Sometimes back , Have a Look(i know its naive way :D) so
let me know if anything wrong , we can use Min-Heap to make solution
efficient isn't it ?
http://shashank7s.blogspot.com/2011/06/given-3-arrays-pick-3-nos-one-from-each.html
Thanks
Shashank Mani
Computer Science
any suggestion on how to approach this problem ??
On Wed, Aug 17, 2011 at 10:37 PM, MAC macatad...@gmail.com wrote:
Given n arrays, find n number such that sum of their differences is
minimum. For e.g. if there are three arrays
A = {4, 10, 15, 20}
B = {1, 13, 29}
C = {5, 14, 28}
find