public boolean canFinish(int numCourses, int[][] prerequisites) {
		int edges = prerequisites.length;
		if (numCourses < 2 || edges < 1)
			return true;
		int[] prereqs = new int[numCourses];
		// Count prerequisites for courses
		for (int i = 0; i < edges; i++)
			prereqs[prerequisites[i][0]]++;
		Queue<Integer> queue = new LinkedList<>();
		// Find courses that do not have prerequisite
		for (int i = 0; i < numCourses; i++) {
			if (prereqs[i] == 0)
				queue.add(i);
		}
		// Initialize number of courses that can be taken to size of queue
		int numsCanTake = queue.size();
		while (!queue.isEmpty()) {
			int course = queue.remove();
			for (int i = 0; i < edges; i++) {
				if (prerequisites[i][1] == course) {
					prereqs[prerequisites[i][0]]--;
					if (prereqs[prerequisites[i][0]] == 0) {
						numsCanTake++;
						queue.add(prerequisites[i][0]);
					}
				}
			}
		}
		return numCourses == numsCanTake;
	}