{"id":22513916,"url":"https://github.com/emahtab/course-schedule-iv","last_synced_at":"2025-07-31T21:03:55.259Z","repository":{"id":79525404,"uuid":"441513959","full_name":"eMahtab/course-schedule-iv","owner":"eMahtab","description":null,"archived":false,"fork":false,"pushed_at":"2022-01-03T02:09:00.000Z","size":51,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T03:26:03.556Z","etag":null,"topics":["floyd-warshall-algorithm","graph","leetcode"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eMahtab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-24T16:46:33.000Z","updated_at":"2022-01-03T02:09:03.000Z","dependencies_parsed_at":"2023-05-23T07:15:55.191Z","dependency_job_id":null,"html_url":"https://github.com/eMahtab/course-schedule-iv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fcourse-schedule-iv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fcourse-schedule-iv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fcourse-schedule-iv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fcourse-schedule-iv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eMahtab","download_url":"https://codeload.github.com/eMahtab/course-schedule-iv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245952209,"owners_count":20699446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["floyd-warshall-algorithm","graph","leetcode"],"created_at":"2024-12-07T03:15:00.755Z","updated_at":"2025-03-28T01:29:26.752Z","avatar_url":"https://github.com/eMahtab.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Course Schedule IV\n## https://leetcode.com/problems/course-schedule-iv\n\nThere 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] = [ai, bi] indicates that you must take course ai first if you want to take course bi.\n\nFor example, the pair [0, 1] indicates that you have to take course 0 before you can take course 1.\n\n**Prerequisites can also be indirect. If course a is a prerequisite of course b, and course b is a prerequisite of course c, then course a is a prerequisite of course c.**\n\n\nYou are also given an array queries where queries[j] = [uj, vj]. For the jth query, you should answer whether course uj is a prerequisite of course vj or not.\n\nReturn a boolean array answer, where answer[j] is the answer to the jth query.\n\n![Course Schedule IV](example.JPG?raw=true)\n\n# Implementation : Floyd Warshall Algorithm O(n^3)\n```java\nclass Solution {\n    public List\u003cBoolean\u003e checkIfPrerequisite(int n, int[][] prerequisites, int[][] queries) {\n        boolean[][] connected = new boolean[n][n];\n        for (int[] p : prerequisites)\n            connected[p[0]][p[1]] = true; // p[0] -\u003e p[1]\n        for (int k = 0; k \u003c n; k++)\n            for (int i = 0; i \u003c n; i++)\n                for (int j = 0; j \u003c n; j++)\n                    connected[i][j] = connected[i][j] || connected[i][k] \u0026\u0026 connected[k][j];\n        List\u003cBoolean\u003e result = new ArrayList\u003c\u003e();\n        for (int[] q : queries)\n            result.add(connected[q[0]][q[1]]);\n        return result;\n    }\n}\n```\n\n# References :\nhttps://www.youtube.com/watch?v=oNI0rf2P9gE (Abdul Bari, Floyd Warshall : All Pairs Shortest Path Algorithm)\n\nhttps://leetcode.com/problems/course-schedule-iv/discuss/660509/JavaPython-FloydWarshall-Algorithm-Clean-code-O(n3)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fcourse-schedule-iv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femahtab%2Fcourse-schedule-iv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fcourse-schedule-iv/lists"}