
JOB UPDATES, COURSES AND TECHNOLOGY NEWS
June 20, 2025 at 07:25 AM
public String goldCoins(int input1, String[] input2, int input3) {
// Write code here ...
String maxCoin = "";
int maxVal = Integer.MIN_VALUE;
for (String code : input2) {
int year = Integer.parseInt(code.substring(1, 3));
int val = Integer.parseInt(code.substring(4));
int resale = val + (input3 - year) * 5;
if (resale > maxVal) {
maxVal = resale;
maxCoin = code;
}
}
return maxCoin;
} // change variables, add dummy lines, change
looping Gold Coin Problem