Facebook
From Bitty Mousedeer, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 44
  1. import java.util.ArrayList;
  2. import java.util.Arrays;
  3. import java.util.List;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.        // System.out.println("test");
  9.         List<List<String>> temp = new ArrayList<>();
  10.  
  11.         List<String> o = new ArrayList<>(2);
  12.         o.add("cm");
  13.         o.add("mc");
  14.         temp.add(o);
  15.  
  16.         o = new ArrayList<>(2);
  17.         o.add("ccm");
  18.         o.add("mc");
  19.         temp.add(o);
  20.  
  21.         o = new ArrayList<>(2);
  22.         o.add("pm");
  23.         o.add("mc");
  24.         temp.add(o);
  25.  
  26.         o = new ArrayList<>(2);
  27.         o.add("c");
  28.         o.add("mc");
  29.         temp.add(o);
  30.  
  31.         System.out.println(fun(temp));
  32.     }
  33.  
  34.     public static int fun(List<List<String>> temp){
  35.         int count = 0;
  36.         for(List<String> one : temp){
  37.             String prod = one.get(0);
  38.             String tem = one.get(1);
  39.  
  40.             char[] prodAr = prod.toCharArray();
  41.             char[] temAr = tem.toCharArray();
  42.  
  43.             Arrays.sort(prodAr);
  44.             Arrays.sort(temAr);
  45.  
  46.             String prod1 = String.valueOf(prodAr);
  47.             String tem1 = String.valueOf(temAr);
  48.  
  49.             if(!prod1.equals(tem1)){
  50.                 count++;
  51.             }
  52.         }
  53.         return count;
  54.     }
  55. }
  56.