题解 | #最大差值#
最大差值
https://www.nowcoder.com/practice/a01abbdc52ba4d5f8777fb5dae91b204
import java.util.*; public class Solution { public int getDis (int[] A, int n) { // write code here int max = 0; int a = 0; for (int i = 1; i < n; i++){ if (A[i] - A[a] > max){ max = A[i] - A[a]; } if (A[i] < A[a]){ a = i; } } return max; } }