Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author nur
- */
- public class GuntingBatuKertas {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n;
- String s1, s2;
- Map<String, String> libs = new HashMap<>();
- libs.put("G", "K");
- libs.put("B", "G");
- libs.put("K", "B");
- n = sc.nextInt();
- s1 = sc.next();
- s2 = sc.next();
- int result = 0;
- for (int j = 0; j < s1.length(); j++) {
- String cur = String.valueOf(s1.charAt(j));
- String toCheck = libs.get(cur);
- int index = s2.indexOf(toCheck);
- if (index != -1) {
- result++;
- s2 = s2.substring(0, index) + s2.substring(index + 1);
- }
- }
- System.out.println(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement