2016. Maximum Difference Between Increasing Elements
https://leetcode.com/problems/maximum-difference-between-increasing-elements
Description
Given a 0-indexed integer array nums
of size n
, find the maximum difference between nums[i]
and nums[j]
(i.e., nums[j] - nums[i]
), such that 0 <= i < j < n
and nums[i] < nums[j]
.
Return the maximum difference. If no such i
and j
exists, return -1
.
Example 1:
Example 2:
Example 3:
Constraints:
n == nums.length
2 <= n <= 1000
1 <= nums[i] <= 109
ac
Last updated