Daily bit(e) of C++ #205, Common interview problem: Splitting marbles.
The question is not understandable. How did you reach the numbers 14 and 22? From where did 2+4+8 came from ?
Section i..j has value values[i]+values[j]. Therefore (values[0]+values[0]) + (values[1]+values[1]) + (values[2]+values[4]) == 2+4+8 == 14 and (values[0]+values[2]) + (values[3]+values[3]) + (values[4]+values[4]) == 4+8+10 == 22.
The question is not understandable. How did you reach the numbers 14 and 22? From where did 2+4+8 came from ?
Section i..j has value values[i]+values[j]. Therefore (values[0]+values[0]) + (values[1]+values[1]) + (values[2]+values[4]) == 2+4+8 == 14 and (values[0]+values[2]) + (values[3]+values[3]) + (values[4]+values[4]) == 4+8+10 == 22.