Sum of Positive Adjacent Differences
Asked at Amazon · Coding Questions · Difficulty: Easy
Given an integer array `nums`, compute the sum of all positive adjacent differences: `sum over i of max(0, nums[i] - nums[i-1])`. (Equivalently, the maximum profit from unlimited buy/sell transactions on a price series.)
Loading the problem…