• + 0 comments

    It is a[p-1] for a[p] ie. the difference between two successive elements.

    Well ,now ,i understood my mistake . I was just adding the positive differences. But the problem requires maximum element in an array , so there must be a comparison while adding the differences.

    Well thanks!