Tap here to switch tabs
Problem
Submissions

Problem: Maximum Difference Between Increasing Elements

med
30 min
Try to solve the Maximum Difference Between Increasing Elements problem.

Statement

Given an integer array nums, choose indices i and j such that i < j and nums[i] < nums[j]. Define the value of this pair as nums[j] - nums[i].

Return the maximum possible value over all valid pairs. If no valid pair exists, return −1-1.

Constraints:

  • n == nums.length

  • 2≤2 \leq n ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Difference Between Increasing Elements

med
30 min
Try to solve the Maximum Difference Between Increasing Elements problem.

Statement

Given an integer array nums, choose indices i and j such that i < j and nums[i] < nums[j]. Define the value of this pair as nums[j] - nums[i].

Return the maximum possible value over all valid pairs. If no valid pair exists, return −1-1.

Constraints:

  • n == nums.length

  • 2≤2 \leq n ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤109\leq 10^9