您的位置:首页 > 编程语言

牛客网2016校招真题在线编程之最大差值

2017-11-26 02:28 323 查看

 

直接暴力搜即可。

 

AC代码:

import java.util.*;

public class LongestDistance {

public int getDis(int[] A, int n) {
int res = Integer.MIN_VALUE;
for(int i=0; i<A.length-1; i++){
for(int j=i+1; j<A.length; j++){
res = Math.max(A[j]-A[i], res);
}
}
return res;
}

}

  

题目来源: https://www.nowcoder.com/practice/1f7675ae7a9e40e4bd04eb754b62fd00?tpId=49&tqId=29281&tPage=1&rp=1&ru=/ta/2016test&qru=/ta/2016test/question-ranking

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: