解题思路:把第一个一维数组的两个元素分别定义为最大值和id,之后遍历进行判断
class Solution {
public int hardestWorker(int n, int[][] logs) {
int max = logs[0][1];
int id = logs[0][0];
for (int i = 1; i < logs.length; i++) {
if(logs[i][1] - logs[i-1][1] > max){
max = logs[i][1] - logs[i-1][1];
id = logs[i][0];
}else if(max == logs[i][1] - logs[i-1][1]){
if(logs[i][0] > id){
id = id;
}else{
id = logs[i][0];
}
}
}
return id;
}
}