Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Incorrect expected result for testcase n= 7 edges = [[1,0],[1,2],[3,4],[4,5],[5,6]]

Utkarsh Gupta

Jan 20, 2024

In the below testcase, the expected result is not correct. If you see, the graph has two source nodes with indegree 0, therefore the expected answer should be [1,3] not [1].

WrongAnswer

0.3 ms

Your Input

7

[[1,0],[1,2],[3,4],[4,5],[5,6]]

Output

[1,3]

Expected

[1]

0

0

Comments
Comments
J
Jimmy 2 years ago

Works for me in C++. I'm getting [1, 3] for both output and expected. What language are you using?

Mohammed Dh Abbas
Mohammed Dh Abbasa year ago

nope. you should consider the 0 node too as its part of the n nodes

On this page