Skip to content

Instantly share code, notes, and snippets.

@terracotta-ko
Created November 17, 2021 03:23
leetcode 2016
class Solution {
fun maximumDifference(nums: IntArray): Int {
var min = Int.MAX_VALUE
var ans = -1
for(n in nums) {
if(n <= min) {
min = n
} else {
ans = Math.max(ans, n - min)
}
}
return ans
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment