File: root - text - article - 2019 - 11 - course.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 1729 Views, 18278 Search Bots | 159 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 1729 Views, 18278 Search Bots | 159 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by Google:
By the way, check out our NEW project AlgoPro (http://algopro.com) for over 60+ video coding sessions with ex-Google/ex-Facebook engineers.
You are given a hash table where the key is a course code, and the value is a list of all the course codes that are prerequisites for the key. Return a valid ordering in which we can complete the courses. If no such ordering exists, return NULL.
Example:
This input should return the order that we need to take these courses:
['CSC100', 'CSC200', 'CSCS300']
Here's your starting point:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 1729 Views, 18278 Search Bots | 159 Words By the way, check out our NEW project AlgoPro (http://algopro.com) for over 60+ video coding sessions with ex-Google/ex-Facebook engineers.
You are given a hash table where the key is a course code, and the value is a list of all the course codes that are prerequisites for the key. Return a valid ordering in which we can complete the courses. If no such ordering exists, return NULL.
Example:
{
'CSC300': ['CSC100', 'CSC200'],
'CSC200': ['CSC100'],
'CSC100': []
}
This input should return the order that we need to take these courses:
['CSC100', 'CSC200', 'CSCS300']
Here's your starting point:
def courses_to_take(course_to_prereqs):
# Fill this in.
courses = {
'CSC300': ['CSC100', 'CSC200'],
'CSC200': ['CSC100'],
'CSC100': []
}
print courses_to_take(courses)
# ['CSC100', 'CSC200', 'CSC300']
Related Articles
- Reverse a Directed Graph
- Skip the readings, focus on problems. And use all the hints!
- Daily Interview Problem: Min Range Needed to Sort
- Maximum In A Stack
- Algorithm Interview: Convert Roman Numerals to Decimal
- Invert a Binary Tree
- Algorithm Interview Question: Symmetric k-ary Tree
- Number of Ways to Climb Stairs
- Daily Interview Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals
- Longest Substring Without Repeating Characters
©2006~2024 SteakOverCooked - 0.01181 Seconds(s) - 1582.511 KB/s - 34 Online Memory: 491.77 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !