#139 Group with the Most First Places
A string contains an id, group name, country, and competition placements. Implement a method that returns the name of the group with the largest number of first-place finishes.
public class Main {
public static void main(String[] args) {
String data = "1;Group1;Canada;1;2;3;4;5;" + "\n" +
"2;Group2;USA;3;4;5;2;4;6;" + "\n" +
"3;Group3;Russia;3;1;5;3;4;5;" + "\n" +
"4;Group4;Germany;3;4;1;5;6;" + "\n" +
"5;Group5;Japan;3;4;5;3;4;6;" + "\n" +
"6;Group6;China;3;4;5;2;3;5;6;";
String result = findGroupWithMostFirstPlaces(data);
System.out.println(result);
}
public static String findGroupWithMostFirstPlaces(String data) {
// your code
}
}Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor