Grokking Graph Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
I'm confused on the line:inDegree.put(i,0);graph.put(i, new ArrayList());what ex...

Matthew Espinoza

Oct 24, 2022

I'm confused on the line:

inDegree.put(i,0); graph.put(i, new ArrayList());

what exactly are they looking to achieve?

0

0

Comments
Comments
Design Gurus
Design Gurus3 years ago

These two lines are setting up the two data structures required to build the graph.

For every vertex in the graph, we need to count its in-degree and incoming edges in a list.

On this page