SHARE
TWEET

CurseOfGul'dan

nikeza Jan 18th, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package curseOfGuldan;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.Scanner;
  6.  
  7. public class CurseOfGuldan {
  8.     public static void main(String[] args) {
  9.         Scanner scanner = new Scanner(System.in);
  10.         int num = Integer.parseInt(scanner.nextLine());
  11.  
  12.         for (int i = 0; i < num; i++) {
  13.             String[] data = scanner.nextLine().split("\\s+");
  14.             String[] dna = data[0].split("");
  15.             String[] virus = data[1].split("");
  16.  
  17.             List<Integer> index = new ArrayList<>();
  18.  
  19.             for (int j = 0; j <= dna.length - virus.length; j++) {
  20.                 int notCoincidence = 0;
  21.                 for (int k = 0; k < virus.length; k++) {
  22.                     if (!dna[j + k].equals(virus[k])) {
  23.                         notCoincidence++;
  24.                     }
  25.                 }
  26.                 if (notCoincidence<2)
  27.                 index.add(j);
  28.             }
  29.  
  30.             if (index.size()==0){
  31.                 System.out.println("No Matches!");
  32.             }else {
  33.                 System.out.println(index.toString().replaceAll("[\\[\\],]", ""));
  34.             }
  35.  
  36.         }
  37.  
  38.  
  39.     }
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top