title: Check whether 2 nodes have any common parent(s) in a DAG graph
body: <p><strong>The input is:</strong></p>
  <p>An <code>int[][]</code>, each sub array contains 2 int as {parent, child}, means there is a path from <code>parent</code> -&gt; <code>child</code>.</p>
  <p>e.g</p>
  <pre><code>{ { 1, 3 }, { 2, 3 }, { 3, 6 }, { 5, 6 }, { 5, 7 }, { 4, 5 }, { 4, 8 }, { 8, 9 } };
  </code></pre>
  <p>Or as a tree structure:</p>
  <pre>
    1   2   4
     \ /   / \
      3   5   8
       \ / \   \
        6   7   9
  </pre>
  <p><strong>The task is:</strong></p>
  <p>Ｇiving 2 value (x, y), return a boolean value, to indicate whether they have any common parent(s).</p>
  <p>Sample input and output:</p>
  <pre>
  [3, 8] => false
  [5, 8] => true
  [6, 8] => true
  </pre>
  <p><strong>My idea:</strong></p>
  <ul>
  <li>Represent the input data as a DAG graph, in which data are stored in a Map like this <code>Map&lt;Integer, LinkedList&lt;Integer&gt;&gt;</code>, where key is the vertex, value is its adjacency list. And the direction in graph is reversed <em>(compared to input data)</em> as <code>child -&gt; parent</code>, so that easy to search for parent.</li>
  <li>Use a function <code>findAvailableParents(Integer vertex)</code> to find all parents (direct and indirect) for a single vertex, and return <code>Set&lt;Integer&gt;</code>.</li>
  <li>Thus, only need to call <code>findAvailableParents()</code> once for each input vertex, then compare whether the 2 returned <code>Set</code>s have any intersection. Ｉf yes, then they have common parent; otherwise, they don't.</li>
  </ul>
  <p><strong>My questions are:</strong></p>
  <ul>
  <li>The time complexity in the solution above is between O(1) ~ O(E), right? <em>(E is edge counts in the graph)</em></li>
  <li>Is there a better solution?</li>
  </ul>