Difficulty: Medium
Acceptance: 51.77%
Points: 30.00
You are given n tasks, labeled from 0 to n-1, and a list of m prerequisite pairs. Each pair [a, b] indicates that task a depends on task b and must be completed after it. Your goal is to determine an order in which to complete all the tasks. - There may be multiple valid orders; return any one of them. - If it is impossible to complete all tasks due to circular dependencies, return an empty array. The driver code will print "No Ordering Possible" when this happens. - If a valid order is returned, the output will be 1. If the order is invalid, the output will be 0. The task is to complete the function **findOrder(**) which takes two integers n, and m and a list of lists of size m\*2 denoting the prerequisite pairs as input and returns any correct order to finish all the tasks. Return an empty array if it's impossible to finish all tasks.
Expected Time Complexity: O(n+m).
Expected Auxiliary Space: O(n+m).
