Maximum difference using Kadane's algorithm