package hackerrank;

import java.util.Scanner;

/**
 * https://www.hackerrank.com/challenges/beautiful-pairs
 */
public class BeautifulPairs {
    private static int beautifulParis(int[] a, int[] b) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = in.nextInt();
        }
        System.out.println(beautifulParis(a, b));
    }
}

@@ -14,16 +14,64 @@
 rrank;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A
 import j
@@ -88,16 +88,16 @@
 canner;%0A
-
 %0A/**%0A * 
@@ -222,28 +222,391 @@
 ulPa
-ris(int%5B%5D a, int%5B%5D b
+irs(int%5B%5D a, int%5B%5D b) %7B%0A        Map%3CInteger, Integer%3E countMap = new HashMap%3C%3E();%0A        for (int i = 0; i %3C a.length; i++) %7B%0A            if (!countMap.containsKey(a%5Bi%5D)) %7B%0A                countMap.put(a%5Bi%5D, 1);%0A            %7D else %7B%0A                countMap.put(a%5Bi%5D, countMap.get(a%5Bi%5D) + 1);%0A            %7D%0A        %7D%0A        int result = 0;%0A        for (int i = 0; i %3C b.length; i++
 ) %7B%0A
@@ -617,32 +617,487 @@
     
+ 
-// TODO%0A        return 0
+   if (countMap.containsKey(b%5Bi%5D)) %7B%0A                int count = countMap.get(b%5Bi%5D);%0A                int newCount = count - 1;%0A                if (newCount == 0) %7B%0A                    countMap.remove(b%5Bi%5D);%0A                %7D else %7B%0A                    countMap.put(b%5Bi%5D, newCount);%0A                %7D%0A                result++;%0A            %7D%0A        %7D%0A        if (countMap.size() == 0) %7B%0A            result--;%0A        %7D else %7B%0A            result++;%0A        %7D%0A        return result
 ;%0A  
@@ -1481,18 +1481,18 @@
 utifulPa
-r
 i
+r
 s(a, b))

Solve Beautiful Pairs