Wipro Interview Question

Consecutive stone pile merge problem