GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesRedundant Cable

Gamified challenge · Union-find

Redundant Cable

A network has nodes 1…n and exactly n cables; edges[i] = [u, v] joins u and v (cables work both ways). Without one of them the network would be a tree: connected, with no loops.

Write redundant(edges) that returns the cable to remove so that a tree is left. If several cables would do (any cable on the loop), return the one that comes last in edges. Return it as [u, v]; either order of the two ends is fine.

Example: [[1, 2], [1, 3], [2, 3]] → [2, 3]. All three cables are on the loop, and [2, 3] is listed last.

Sign in to play Redundant Cable

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account