Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
1
Indexable
Never
import java.io.*;
import java.util.*;

public class Main {

    static ArrayList<String> getStrings(ArrayList<String> arr)
	{
ArrayList<String> getString = new  ArrayList<String>();
	 String[]  rows= {"qwertyuiop","asdfghjkl","zxcvbnm"};
	
	for(int i=0; i<arr.size(); i++)
	{
		boolean b=false;
		   for(int j=0; j<rows.length; j++)
			{
				boolean f=true;

				 for(int k=0; k<arr.get(i).length(); k++)
					{
						char ch=arr.get(i).charAt(k);
						if(rows[i].indexOf(ch)==-1)
						{
							f=false;
							break;
						}
						
					}
				if(f==true)
				{
					b=true;
					break;
				}
				
			}
		if(b==true)
		{
			getString.add(arr.get(i));
		}
		
		
	}

		return getString;

		
    }

    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
    
        int n = sc.nextInt();
        ArrayList<String> arr = new ArrayList<String>();
        for(int i = 0; i < n; i++){
            String s = sc.next();
            arr.add(s);
        }

        ArrayList<String> result = getStrings(arr);
        for(int i = 0; i < result.size(); i++){
            System.out.println(result.get(i));
        }
    }
}