题解 | #最大差值#
最大差值
https://www.nowcoder.com/practice/a01abbdc52ba4d5f8777fb5dae91b204?tpId=182&tqId=34641&rp=1&ru=%2Fexam%2Foj&qru=%2Fexam%2Foj&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26pageSize%3D50%26search%3D%26tab%3D%25E5%2590%258D%25E4%25BC%2581%25E7%259C%259F%25E9%25A2%2598%26topicId%3D182&difficulty=undefined&judgeStatus=undefined&tags=&title=
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param A int整型一维数组 * @param n int整型 * @return int整型 */ function getDis( A , n ) { // write code here let min = A[0]; let max = 0; for(let i =1; i<n; i++){ min = Math.min(min, A[i]); max = Math.max(A[i]-min, max); } return max } module.exports = { getDis : getDis };