Skip to content

Commit 6d6aff5

Browse files
committed
Create README - LeetHub
1 parent 07da75d commit 6d6aff5

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

redundant-connection-ii/README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<h2>685. Redundant Connection II</h2><h3>Hard</h3><hr><div><p>In this problem, a rooted tree is a <b>directed</b> graph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one parent, except for the root node which has no parents.</p>
2+
3+
<p>The given input is a directed graph that started as a rooted tree with <code>n</code> nodes (with distinct values from <code>1</code> to <code>n</code>), with one additional directed edge added. The added edge has two different vertices chosen from <code>1</code> to <code>n</code>, and was not an edge that already existed.</p>
4+
5+
<p>The resulting graph is given as a 2D-array of <code>edges</code>. Each element of <code>edges</code> is a pair <code>[u<sub>i</sub>, v<sub>i</sub>]</code> that represents a <b>directed</b> edge connecting nodes <code>u<sub>i</sub></code> and <code>v<sub>i</sub></code>, where <code>u<sub>i</sub></code> is a parent of child <code>v<sub>i</sub></code>.</p>
6+
7+
<p>Return <em>an edge that can be removed so that the resulting graph is a rooted tree of</em> <code>n</code> <em>nodes</em>. If there are multiple answers, return the answer that occurs last in the given 2D-array.</p>
8+
9+
<p>&nbsp;</p>
10+
<p><strong>Example 1:</strong></p>
11+
<img alt="" src="https://assets.leetcode.com/uploads/2020/12/20/graph1.jpg" style="width: 222px; height: 222px;">
12+
<pre><strong>Input:</strong> edges = [[1,2],[1,3],[2,3]]
13+
<strong>Output:</strong> [2,3]
14+
</pre>
15+
16+
<p><strong>Example 2:</strong></p>
17+
<img alt="" src="https://assets.leetcode.com/uploads/2020/12/20/graph2.jpg" style="width: 222px; height: 382px;">
18+
<pre><strong>Input:</strong> edges = [[1,2],[2,3],[3,4],[4,1],[1,5]]
19+
<strong>Output:</strong> [4,1]
20+
</pre>
21+
22+
<p>&nbsp;</p>
23+
<p><strong>Constraints:</strong></p>
24+
25+
<ul>
26+
<li><code>n == edges.length</code></li>
27+
<li><code>3 &lt;= n &lt;= 1000</code></li>
28+
<li><code>edges[i].length == 2</code></li>
29+
<li><code>1 &lt;= u<sub>i</sub>, v<sub>i</sub> &lt;= n</code></li>
30+
<li><code>u<sub>i</sub> != v<sub>i</sub></code></li>
31+
</ul>
32+
</div>

0 commit comments

Comments
 (0)