Motive Interview Question

There was a coding problem where I had to calculate maximum profit in a array by comparing the adjacent values.