Asked inCaptain Fresh,Backend Engineer SDE 1

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...
Captain Fresh Backend Engineer SDE 1 Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter