SarthakKeshari / Java-Questions-and-Solutions

This repository aims to solve and create new problems from different spheres of coding. A path to help students to get access to solutions and discuss their doubts.
MIT License
47 stars 98 forks source link

[ISSUE-287] add program to solve CourseSolution problem #292

Closed ravi0213 closed 3 years ago

ravi0213 commented 3 years ago

Issue Id you have worked upon -

287

Briefly explain your program logic -

Approach: Topological Sorting, Cycle Detection Let's try to think of prerequisites pairs as an edge between two nodes in a graph. Now this problem becomes simple, we just need to find out if there is any cycle in a graph or not. If there is no cycle, then we can finish all the courses otherwise the answer is no.

Screenshots(Attach 2 screenshots of your own input and output) -

Attach here

Screen Shot 2021-10-07 at 17 39 54 Screen Shot 2021-10-07 at 17 40 17


Checklist:

Eg - If your code follow the below guidelines. Kindly change [] to [x]

All the conditions should be fulfilled for considering your code for merging -

ravi0213 commented 3 years ago

@SarthakKeshari Could you please review this PR? Thanks