Skip to content

Instantly share code, notes, and snippets.

@junminstorage
Last active December 5, 2020 04:26
Show Gist options
  • Save junminstorage/9dbb9312785988e8ead64acb74b56ad6 to your computer and use it in GitHub Desktop.
Save junminstorage/9dbb9312785988e8ead64acb74b56ad6 to your computer and use it in GitHub Desktop.
Given a list of tasks with execution time of each task and its dependecies.
e.g.
A, 2 <== task A needs 2 timeunits to finish
B, 3 <== taks B needs 3 timeunits to finish
C, 5
D, 3
B, C can run only after A finishes. D can run only after B finished.
A -> B,C
B -> D
The task scheduler should output the followings:
["A,2", "B,C,3", "C,D,2", "D,1"]
which means:
step1: A, 2. <== A will start first, finish in 2 timeunits
step2: B, C, 3 <== B will finish in step 2, but C won't
step3: C, D, 2 <== C will finish in step 3, but D won't
step4: D, 1
Implement the following method:
List<String> scheduler(Map<String, Integer> taskExecutionTime, Map<String, String> dependencies)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment