Developer-Student-Clubs-VSSUT-Burla / Master-PyAlgo

36 stars 84 forks source link

Topological Sort #355

Open Fatema110 opened 3 years ago

Fatema110 commented 3 years ago

You're given a list of arbitrary jobs that need to be completed. These jobs are in form of distinct integer numbers. You're also given a list of dependencies.A dependency is represented as a pair of job where the first job is a prerequisite of second job i.e. the second job is dependent on first one, it can only be completed once the first job is completed .

Write a function that takes a list of jobs and list of dependencies and return a list containing a valid order in which jobs are completed if no such order exists then function should return an empty array.

Jobs : [1,2,3,4] deps : [ [1,2] , [1,3] , [3,2] , [4,2] , [4,3] ]

Fatema110 commented 3 years ago

@rcoder23 please assign me this.

rcoder23 commented 3 years ago

@Fatema110 You can work on it