feat: populate note files with problem descriptions and code stubs
Add populate-notes.mjs that fetches problem descriptions and Python/C++ code stubs from LeetCode's GraphQL API. Populated all 197 NeetCode 150 note files with: - Problem description (examples, constraints) - Python code stub (function signature) - C++ code stub (function signature + includes) API responses cached in leetcode/.cache/leetcode/ for instant re-runs.
This commit is contained in:
@@ -1,18 +1,64 @@
|
||||
#+PROPERTY: STUDY_DECK_02
|
||||
* TODO 0207. Course Schedule :medium:
|
||||
:PROPERTIES:
|
||||
:NEETCODE: [[file:../../roadmap.org::*0207. Course Schedule][Roadmap]]
|
||||
:NEETCODE: [[file:../../roadmap.org::*0207. Course Schedule][0207. Course Schedule]]
|
||||
:END:
|
||||
|
||||
There are a total of ~numCourses~ courses you have to take, labeled from ~0~ to ~numCourses - 1~. You are given an array ~prerequisites~ where ~prerequisites[i] = [a_{i}, b_{i}]~ indicates that you *must* take course ~b_{i}~ first if you want to take course ~a_{i}~.
|
||||
|
||||
- For example, the pair ~[0, 1]~, indicates that to take course ~0~ you have to first take course ~1~.
|
||||
|
||||
Return ~true~ if you can finish all courses. Otherwise, return ~false~.
|
||||
|
||||
*Example 1:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: numCourses = 2, prerequisites = [[1,0]]
|
||||
Output: true
|
||||
Explanation: There are a total of 2 courses to take.
|
||||
To take course 1 you should have finished course 0. So it is possible.
|
||||
#+end_src
|
||||
|
||||
|
||||
*Example 2:*
|
||||
|
||||
|
||||
#+begin_src
|
||||
Input: numCourses = 2, prerequisites = [[1,0],[0,1]]
|
||||
Output: false
|
||||
Explanation: There are a total of 2 courses to take.
|
||||
To take course 1 you should have finished course 0, and to take course 0 you should also have finished course 1. So it is impossible.
|
||||
#+end_src
|
||||
|
||||
|
||||
*Constraints:*
|
||||
|
||||
- ~1 <= numCourses <= 2000~
|
||||
|
||||
- ~0 <= prerequisites.length <= 5000~
|
||||
|
||||
- ~prerequisites[i].length == 2~
|
||||
|
||||
- ~0 <= a_{i}, b_{i} < numCourses~
|
||||
|
||||
- All the pairs prerequisites[i] are *unique*.
|
||||
|
||||
** TODO Approach
|
||||
Write your approach here.
|
||||
|
||||
** TODO Python
|
||||
#+begin_src python
|
||||
|
||||
class Solution:
|
||||
def canFinish(self, numCourses: int, prerequisites: List[List[int]]) -> bool:
|
||||
#+end_src
|
||||
|
||||
** TODO C++
|
||||
#+begin_src cpp
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
bool canFinish(int numCourses, vector<vector<int>>& prerequisites) {
|
||||
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
Reference in New Issue
Block a user