I had a programming test yesterday. On of the questions was:
Given an array of numbers
[4, 6, 8, 3]
Work out how many steps it takes to make them all the same number if you can only increment them by +1/-1 per step.
I worked out the average of the array then took the difference between the average and the number furtherest away from it. Was this correct?
Jan 18, 2011 6:34pm PST