hey @NeetCodeIO, you ordering pairs in prerequisites from right to left, but in explanation of this task on Leetcode there are direction from left to right, is it mistake of Leetcode platform or yours?
Here neetcode's explanation A -> B does not indicate that A is a prerequisite of B (like what this notation meant e.g. in course schedule I and II problem) instead the arrow here indicates all the nodes which are (direct) prerequisites of A. So here we are analyzing the inverted relationship i.e. instead of looking for all the nodes which are prerequisite of a node, we are looking for all the direct prerequisite nodes of a particular node .
public List checkIfPrerequisite(int numCourses, int[][] prerequisites, int[][] queries) { List list = new ArrayList(); Map map = new HashMap(); for (int i=0;i
hey @NeetCodeIO, you ordering pairs in prerequisites from right to left, but in explanation of this task on Leetcode there are direction from left to right, is it mistake of Leetcode platform or yours?
Here neetcode's explanation A -> B does not indicate that A is a prerequisite of B (like what this notation meant e.g. in course schedule I and II problem) instead the arrow here indicates all the nodes which are (direct) prerequisites of A. So here we are analyzing the inverted relationship i.e. instead of looking for all the nodes which are prerequisite of a node, we are looking for all the direct prerequisite nodes of a particular node .
Is there a method to which new problems you upload? Or do you just upload whatever problem you’re practicing at the time?
Daily Leetcode Problems.
What's the space complexity? Is it the same as the time complexity?
Once you use hashmap to store what nodes that current node can reach, time complexity of running DFS can be O(N+E) instead O(N(N+E))?
I have been following these course schedule problems but one thing i didn't understand is how is the time complexity O(P+N)?? Can someone explain??
You’re only visiting the nodes and edges once which makes it O(V+E)
I think Kahns is more straightforward
Hey NeetCode … you know what? You are the best…
chaatu
Hey Neet,
can you make video on how to stay ahead with rise of AI as a programmer?
Help: looking for solution of leetcode 1203: sort-items-by-groups-respecting-dependencies
class Solution {
Map set = new HashMap();
public List checkIfPrerequisite(int numCourses, int[][] prerequisites, int[][] queries) {
List list = new ArrayList();
Map map = new HashMap();
for (int i=0;i
Today's problem can be found here: th-cam.com/video/K-RYzDZkzCI/w-d-xo.html
can we use union find ?
You cannot use union find in directed graphs
made it so easy
interviewing amazon intern tomorrow, this video will help me get that offer!