11078 - Open Credit System


Difficulty : easy

Solution Description :

Ad hoc problem 

Try to find the max difference between any two number in the sequence in O(n) time. 
Keep your mind i is senior and j is junior if i<j (Here i and j is the sequence number)
Example:
Sequence--------Marks
1                10
2                20
3                11
4                9
In above example marks 10 is senior of 20,11,and 9. Marks 20 is senior of 11 and 9. Marks 11 is senior of 9.

You first need to find the maximum marks of senior.
In above example, when your are in sequence no 3 then the maximum marks of senior is 20.

After that you need to find the maximum difference of marks.
1. If (maximum marks of senior - current marks) is greater than maximum difference
   then change the maximum difference value.
2. If (previous marks - current marks) is greater than maximum difference
   then change the maximum difference value.

at last print the maximum difference.