PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Microsoft

Identify the Extra Directed Edge

Last updated: Apr 12, 2026

Quick Overview

This question evaluates understanding of graph theory concepts—directed trees, parent-child constraints, and cycle detection—and measures competency in reasoning about how a single extra directed edge can violate rooted-tree properties.

  • medium
  • Microsoft
  • Coding & Algorithms
  • Software Engineer

Identify the Extra Directed Edge

Company: Microsoft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are given a list of directed edges `edges`, where each edge is represented as `[parent, child]`. The graph contains nodes labeled from `1` to `n`, and it was originally a rooted tree with exactly one extra directed edge added. A valid rooted tree must satisfy all of the following: - Exactly one node is the root and has no parent. - Every other node has exactly one parent. - All nodes are reachable from the root. - There are no directed cycles. Your task is to return the single edge that should be removed so that the remaining edges form a valid rooted tree. If there are multiple candidate edges, return the one that appears last in the input. Example: - Input: `[[1,2],[1,3],[2,3]]` - Output: `[2,3]`

Quick Answer: This question evaluates understanding of graph theory concepts—directed trees, parent-child constraints, and cycle detection—and measures competency in reasoning about how a single extra directed edge can violate rooted-tree properties.

Related Interview Questions

  • Return Top K Open Businesses - Microsoft (hard)
  • Implement Memory Allocation and In-Memory Records - Microsoft (medium)
  • Implement K-Means and Detect Divisible Subarrays - Microsoft (medium)
  • Sort Three Categories In Place - Microsoft (medium)
  • Retain Top K Elements - Microsoft (medium)
Microsoft logo
Microsoft
Jan 3, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
1
0

You are given a list of directed edges edges, where each edge is represented as [parent, child]. The graph contains nodes labeled from 1 to n, and it was originally a rooted tree with exactly one extra directed edge added.

A valid rooted tree must satisfy all of the following:

  • Exactly one node is the root and has no parent.
  • Every other node has exactly one parent.
  • All nodes are reachable from the root.
  • There are no directed cycles.

Your task is to return the single edge that should be removed so that the remaining edges form a valid rooted tree.

If there are multiple candidate edges, return the one that appears last in the input.

Example:

  • Input: [[1,2],[1,3],[2,3]]
  • Output: [2,3]

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Microsoft•More Software Engineer•Microsoft Software Engineer•Microsoft Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.