Maximum Difference in an Array

You are given an array of integers and must compute the maximum difference between any item and any lower indexed smaller item for the possible pairs, i.e., for a given array a find the maximum value of a[j] – a[i] for all i, j where 0 <= i < j < n and a[i] <…

Read more...

Counting Valleys – HackerRank

Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike he took exactly steps. For every step he took, he noted if it was an uphill, , or a downhill, step. Gary’s hikes start and end at sea level and each step up…

Read more...
Bitnami