ACKO INSURANCE Hiring | Maximum Difference Between Increasing Elements | Off-Campus OA (2021)
Question · Posted Jun 2026
Problem Statement Given a 0-indexed integer array nums, find the maximum value of: nums[j]−nums[i]nums[j] - nums[i]nums[j]−nums[i] such that: i < j nums[i] < nums[j] Return the maximum difference. If no such pair exists, return -1. Example Input nums = [7,1,5,4] Output 4 Explanation Choose: i = 1 → nums[i] = 1 j = 2 → nums[j] = 5 Difference = 5 - 1 = 4 No larger valid difference exists. Constraints 2 <= nums.length <= 1000 1 <= nums[i] <= ...
The full answer & interview discussion are available to premium members.
Log in Create a free account