nope.. lead is the difference, but the output lead is the max lead over all rounds
Read more… (16 words)
nope.. lead is the difference, but the output lead is the max lead over all rounds
Hi,
It would be great if you share the optimum solution for each problem as it can be implemented by many ways.
import java.util.Arrays;import java.util.Scanner;import java.util.regex.Pattern;public class Comp1_LeadGame {public static void main(String[] args) {Scanner input = new Scanner(System.in);System.out.println("No. of rounds: ");int nRounds = input.nextInt();input.nextLine();System.out.println("Scores:");String scoreRegex = "\\d+[ ]+\\d+";int[] output = { 1, 0 }; // assuming player 1 is the winner for tiefor (int i = 0; i < nRounds; i++) {String scores = input.nextLine();if (Pattern.matches(scoreRegex, scores)) {String[] roundScore = scores.split("[ ]+");int scoreDiff = Integer.parseInt(roundScore[0]) - Integer.parseInt(roundScore[1]);