1. You are given n courses named numbered 0 to n-1 and given a prerequisite array of pairs where each element is a pair [a,b] which represents to complete course a the prerequisite is course b which needs to be finished first before doing course a. Tell if you will be able to finish all the courses or not?
Rahul Tiwari
author
3y
The optimized solution was to make an adjacency list of all the prerequisites of all the courses and do a dfs to check if we can complete the courses. If there is a cycle then we cannot complete the c...read more
Help your peers!
Add answer anonymously...
Top Captain Fresh Backend Engineer SDE 1 interview questions & answers
Top HR questions asked in Captain Fresh Backend Engineer SDE 1
>
Captain Fresh Backend Engineer SDE 1 Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app