Skip to content

Commit 89667bd

Browse files
committed
Added some comments
1 parent 2005be4 commit 89667bd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: src/main/java/com/ctci/treesandgraphs/BuildOrder.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
import java.util.stream.Stream;
1111

1212
/**
13+
* You are given a list of projects and a list of dependencies (which is a list of pairs of projects, where the second
14+
* project is dependent on the first project). All of a project's dependencies must be built before the project is. Find
15+
* a build order that will allow the projects to be built. If there is no valid build order, return an error.
16+
* EXAMPLE
17+
* Input: projects: a, b, c, d, e, f and dependencies: (a, d), (f, b), (b, d), (f, a), (d, c)
18+
* Output: f, e, a, b, d, c
19+
*
1320
* @author rampatra
1421
* @since 2019-02-21
1522
*/
@@ -109,7 +116,8 @@ public static void main(String[] args) {
109116
↓ |
110117
f <–– a <–– d <–– c
111118
112-
119+
Note: Project "a" is dependent on "f", and project "d" is dependent on "a", and so on.
120+
113121
*/
114122
BuildOrder buildOrder = new BuildOrder();
115123
buildOrder.addProjects(Stream.of("a", "b", "c", "d", "e", "f"));

0 commit comments

Comments
 (0)