package leetcode;

import java.util.Arrays;
import java.util.List;

/**
 * https://leetcode.com/problems/accounts-merge/
 */
public class Problem721 {
    public List<List<String>> accountsMerge(List<List<String>> accounts) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem721 prob = new Problem721();
        System.out.println(prob.accountsMerge(Arrays.asList(
            Arrays.asList(new String[]{"John", "johnsmith@mail.com", "john00@mail.com"}),
            Arrays.asList(new String[]{"John", "johnnybravo@mail.com"}),
            Arrays.asList(new String[]{"John", "johnsmith@mail.com", "john_newyork@mail.com"}),
            Arrays.asList(new String[]{"Mary", "mary@mail.com"})
        ))); // [["John", 'john00@mail.com', 'john_newyork@mail.com', 'johnsmith@mail.com'],  ["John", "johnnybravo@mail.com"], ["Mary", "mary@mail.com"]]
    }
}

@@ -54,20 +54,68 @@
 va.util.
-List
+HashMap;%0Aimport java.util.List;%0Aimport java.util.Map
 ;%0A%0A/**%0A 
@@ -283,16 +283,16 @@
 // TODO%0A
-
         
@@ -311,16 +311,930 @@
 %0A    %7D%0A%0A
+    private static class UnionFind %7B%0A        private final Map%3CString, String%3E map = new HashMap%3C%3E();%0A%0A        public void connect(String a, String b) %7B%0A            if (!map.containsKey(a)) %7B%0A                map.put(a, a);%0A            %7D%0A            if (!map.containsKey(b)) %7B%0A                map.put(b, b);%0A            %7D%0A            if (isConnected(a, b)) %7B%0A                return;%0A            %7D%0A            for (Map.Entry%3CString, String%3E entry : map.entrySet()) %7B%0A                if (entry.getValue().equals(map.get(a))) %7B%0A                    map.put(entry.getKey(), map.get(b));%0A                %7D%0A            %7D%0A        %7D%0A%0A        public boolean isConnected(String a, String b) %7B%0A            if (!map.containsKey(a)) %7B%0A                return false;%0A            %7D%0A            if (!map.containsKey(b)) %7B%0A                return false;%0A            %7D%0A            return map.get(a).equals(map.get(b));%0A        %7D%0A    %7D%0A%0A
     publ

Update problem 721