Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- class hfak{
- public static void main(String[] args){
- Scanner sc=new Scanner(System.in);
- List<String> output=new ArrayList<String>();
- while(sc.hasNext()){
- int a=sc.nextInt();
- if(a==0)
- break;
- List<String> color=new ArrayList<String>();
- List<Integer> count=new ArrayList<Integer>();
- String c=sc.nextLine();
- String modelcolor=c;
- int modelcount=1;
- while(--a>=0){
- String x=sc.nextLine();
- if (color.contains(x)){
- count.set(color.indexOf(x),count.get(color.indexOf(x))+1);
- if(count.get(color.indexOf(x))>modelcount){
- modelcolor=x;
- modelcount=count.get(color.indexOf(x));
- }
- }
- else{
- color.add(x);
- count.add(1);
- }
- }
- output.add(modelcolor);
- }
- for (int i=0;i<output.size();i++){
- System.out.println(output.get(i));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement