maxDiff to -1 to keep track of the maximum difference.i goes from 0 to n-2 and the inner loop variable j goes from i+1 to n-1.nums[i] < nums[j].nums[j] - nums[i].maxDiff if the calculated difference is greater than the current maxDiff.maxDiff if it's not -1, otherwise return -1.