Amazon Interview Question
Software Engineer in Testsi think its wrong...
Given array:{ 3,23,5,8,14,7} and an amount T=10 ..next lowest peak low_T=8
reduce the first peak 23 by 8: 23-8=15, we have new array {2,15,5,8,14,7}
now,T=10 ..next lowest peak low_T=8 ==> 15-8 ==> new array {2,5,5,8,14,7}
now,T=10 ..next lowest peak low_T=8 ==> 14-8 ==> new array {2,5,5,8,4,7}
now,T=10 ..next lowest peak low_T=8 ==> 8-8 ==> new array {2,5,5,0,4,7}
END
Can you please exaplin, "reduce the peaks of the array by equally to the next lowest peak(s) iteratively until that integer reaches zero." . Sorry Iam not able to understand this. Maybe an example would help.
- Anonymous November 24, 2009