title: Given an unsorted Array find maximum value of A[j] - A[i] where j>i..in O(n) time
body: <p>This is an Amazon interview Question.I have solved this problem in O(n) using dynamic 
  programming.But I want to know can there be more optimization than <strong>O(n)</strong> </p>
  
  <p>for e.g. suppose below is the array </p>
  
  <pre><code>3 7 1 4 2 4 returns 4
  
  5 4 3 2 1 returns Nothing
  
  4 3 2 2 3 returns 1
  </code></pre>
  
  <p>This is the code i have written <a href="http://ideone.com/7Y6Z0" rel="noreferrer">Code</a></p>