Skip to main content
All Questions

Course Schedule

Medium

You are given numCourses and a list of prerequisites, where each element in prerequisites[i] = [a_i, b_i] means you must complete course b_i before taking course a_i. Write a function canFinish that returns True if it's possible to finish all courses, and False if it's not. You need to complete all the courses for the result to be True.

Assume there are no duplicate prerequisites, and numCourses is a non-negative number.

Examples

Input: numCourses = 3, prerequisites = [[2, 1], [1, 0]] Output: True Explanation: You can complete course 0 first, then course 1, and finally course 2. Input: numCourses = 4, prerequisites = [[3, 2], [2, 1], [1, 0], [0, 3]] Output: False Explanation: The prerequisites form a cycle, making it impossible to finish all courses. Input: numCourses = 5, prerequisites = [[4, 2], [3, 1], [2, 0]] Output: True Explanation: You can complete the courses in order from course 0 to course 4.

Interview experiences

9 shared
L
Lumos · 5 days ago
"The screening process was pretty straightforward. It started with a few basic questions about my prior experience, relevant background, and the technical projects I had worked on. From there, the conversation focused on the projects I had mentioned, with questions about my specific contributions, the technologies I used, the challenges I encountered, and how I approached solving technical problems. Overall, the screening was fairly conversational and served mainly to assess my technical foundation, hands-on experience, and ability to clearly explain the work I had done."
Software Engineer · Mid Level / L4
Stripe · 18 days ago
"Overall, the interview process was well-structured and gave me a good opportunity to demonstrate my problem-solving and programming skills. The interviewers were friendly, professional, and encouraged me to think through problems rather than simply focus on getting the final answer. What went well was the clarity of the problems and the collaborative nature of the discussions. I particularly appreciated being able to explain my approach, discuss trade-offs, and receive feedback or hints when appropriate. The process felt focused on understanding how I reasoned about problems rather than just evaluating whether I could produce a solution quickly. One area that could be improved is providing slightly more clarity around expectations for each stage of the process, particularly regarding the scope and format of the technical interviews. Overall, though, I had a positive experience and appreciated the time and effort the interviewers put into making the process fair and engaging."
Software Engineer · Intern
LinkedIn · 24 days ago
"The interviews are scheduled over 2-3 days so the process is quick. They have a phone screen, DS round, DS with AI, System design and Hiring Manager round."
Software Engineer · Mid Level / L4
Google · a month ago
"Throughout the process, I thought out loud, trying to take the interviewer along with me at every single step. He seemed pretty satisfied with my answers. At the end, we discussed the role of an intern at Google and the different teams within the company."
Software Engineer · Intern
Anduril · 2 months ago
"Interviewer was very friendly. Very easy first coding round. You should just brush up on leetcode and identify the patterns."
Software Engineer · Mid Level / L4
Amazon · 8 months ago
"The process was fairly simple, online assessment with 2 coding questions and then multiple choice leadership principles questions (choose the right action for the given scenario). Then around a month later I received an interview invitation for 2 interviews, 1 hour each which consisted of about 40 mins of live coding and 20 mins of CV and competency questions, including AI usage, leadership, teamwork and project deep dives."
Software Engineer · Intern
Netflix · 2 years ago
"Interviews were surprisingly easy and seemed more vibes based. Nothing was ridiculously difficult or unfair. It was more of a "does this kid seem smart and genuine""
Software Engineer · Entry Level / L3
Wish · 2 years ago
"Just regular coding, not much talking, asked to write 2 different solutions and both need to be runnable."
Software Engineer · Mid Level / L4
Amazon · 2 years ago
"It was really good as they do seem to care about interview and i had a great time discussing with the interviewer."
Software Engineer · Entry Level / L3

Related questions

Course Schedules II

Related courses

Course

Machine Learning Engineer Interview Prep

Land your dream machine learning role at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Explore ML system design, core concepts, coding, behavioral interviews, and more.

Course

Data Science Interview Prep

Land your dream data science role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Practice statistics, experimentation, coding, SQL, machine learning, behavioral interviews, and more.