题目链接https://leetcode.cn/problems/WHnhjV/
简单题,不用解释直接看代码
class Solution {
public int giveGem(int[] gem, int[][] operations) {
for(int i=0;i<operations.length;i++){
int x = operations[i][0];
int y = operations[i][1];//x给y
int g = gem[x]/2;
gem[x] -= g;
gem[y] += g;
}
Arrays.sort(gem);
return gem[gem.length-1]-gem[0];
}
}