Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - import java.util.Scanner;
 - public class TitleSearch {
 - public static void main(String[] args) {
 - Scanner scan = new Scanner(System.in);
 - String word = scan.nextLine();
 - int n = Integer.parseInt(scan.nextLine());
 - for (int i = 0; i < n; i++) {
 - String input = scan.nextLine().toLowerCase();
 - StringBuilder result = new StringBuilder(word);
 - int index = 0;
 - for (int j = 0; j < result.length(); j++) {
 - if (index < input.length() && input.charAt(index) == result.charAt(j)) {
 - index++;
 - result.deleteCharAt(j);
 - j--;
 - }
 - }
 - if (index == input.length()) {
 - System.out.println(result);
 - word = result.toString();
 - } else {
 - System.out.println("No such title found!");
 - }
 - }
 - }
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment