Skip to content

Commit c06e4ca

Browse files
Added README.md file for Redundant Connection
1 parent 18dc520 commit c06e4ca

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

684-redundant-connection/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<h2><a href="https://leetcode.com/problems/redundant-connection">Redundant Connection</a></h2> <img src='https://img.shields.io/badge/Difficulty-Medium-orange' alt='Difficulty: Medium' /><hr><p>In this problem, a tree is an <strong>undirected graph</strong> that is connected and has no cycles.</p>
2+
3+
<p>You are given a graph that started as a tree with <code>n</code> nodes labeled from <code>1</code> to <code>n</code>, with one additional edge added. The added edge has two <strong>different</strong> vertices chosen from <code>1</code> to <code>n</code>, and was not an edge that already existed. The graph is represented as an array <code>edges</code> of length <code>n</code> where <code>edges[i] = [a<sub>i</sub>, b<sub>i</sub>]</code> indicates that there is an edge between nodes <code>a<sub>i</sub></code> and <code>b<sub>i</sub></code> in the graph.</p>
4+
5+
<p>Return <em>an edge that can be removed so that the resulting graph is a tree of </em><code>n</code><em> nodes</em>. If there are multiple answers, return the answer that occurs last in the input.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
<img alt="" src="https://assets.leetcode.com/uploads/2021/05/02/reduntant1-1-graph.jpg" style="width: 222px; height: 222px;" />
10+
<pre>
11+
<strong>Input:</strong> edges = [[1,2],[1,3],[2,3]]
12+
<strong>Output:</strong> [2,3]
13+
</pre>
14+
15+
<p><strong class="example">Example 2:</strong></p>
16+
<img alt="" src="https://assets.leetcode.com/uploads/2021/05/02/reduntant1-2-graph.jpg" style="width: 382px; height: 222px;" />
17+
<pre>
18+
<strong>Input:</strong> edges = [[1,2],[2,3],[3,4],[1,4],[1,5]]
19+
<strong>Output:</strong> [1,4]
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;= a<sub>i</sub> &lt; b<sub>i</sub> &lt;= edges.length</code></li>
30+
<li><code>a<sub>i</sub> != b<sub>i</sub></code></li>
31+
<li>There are no repeated edges.</li>
32+
<li>The given graph is connected.</li>
33+
</ul>

0 commit comments

Comments
 (0)