Visa Inc. Interview Question

Had to write a program on hakerrank for comparing consecutive 2 elements in an array based on some condition & fetch the max of the outcomes.