Search
⌘K
Get Premium
Leetcode 2016. Maximum Difference Between Increasing Elements
Find the maximum positive difference nums[j] - nums[i] with i < j and nums[i] < nums[j] in an array, returning -1 if no such increasing pair exists. This is the classic "max profit" / prefix-minimum pattern — track the smallest prior value and update the best difference as you scan.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.