SHARE
TWEET

GuntingBatuKertas - TOKI

ngekoding Feb 23rd, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import java.util.*;
  3.  
  4. /*
  5.  * To change this license header, choose License Headers in Project Properties.
  6.  * To change this template file, choose Tools | Templates
  7.  * and open the template in the editor.
  8.  */
  9. /**
  10.  *
  11.  * @author nur
  12.  */
  13. public class GuntingBatuKertas {
  14.  
  15.     public static void main(String[] args) {
  16.         Scanner sc = new Scanner(System.in);
  17.  
  18.         int n;
  19.         String s1, s2;
  20.         Map<String, String> libs = new HashMap<>();
  21.  
  22.         libs.put("G", "K");
  23.         libs.put("B", "G");
  24.         libs.put("K", "B");
  25.  
  26.         n = sc.nextInt();
  27.  
  28.         s1 = sc.next();
  29.         s2 = sc.next();
  30.  
  31.         int result = 0;
  32.         for (int j = 0; j < s1.length(); j++) {
  33.             String cur = String.valueOf(s1.charAt(j));
  34.             String toCheck = libs.get(cur);
  35.  
  36.             int index = s2.indexOf(toCheck);
  37.             if (index != -1) {
  38.                 result++;
  39.                 s2 = s2.substring(0, index) + s2.substring(index + 1);
  40.             }
  41.  
  42.         }
  43.         System.out.println(result);
  44.  
  45.     }
  46. }
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