Skip to content

Conversation

@ErdemT09
Copy link
Collaborator

In both solutions, I removed unnecessary nested procedures to individual methods, making the code more modular.
I have also replaced the HashMap in the DFS solution with an ArrayList as we had done with the BFS solution.

This was linked to issues May 12, 2021
private void createMap(int[][] courses) {

inDegreeMap = new int[numOfCourses + 1];
courseChiMap = new LinkedList<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should convert this to:
courseChiMap = new ArrayList<>();

Otherwise, it will take 85ms instead of 8ms.

}

private void createMap(int n, int[][] relations) {
courseChiMap = new LinkedList<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also change this to:
courseChiMap = new ArrayList<>();

Otherwise it will take 80ms instead of 5ms.

Copy link
Collaborator Author

@ErdemT09 ErdemT09 May 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added both.

Copy link
Collaborator

@altay9 altay9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for refactoring. Quite clear.

@ErdemT09 ErdemT09 merged commit 3b0d4ef into master May 12, 2021
@ErdemT09 ErdemT09 deleted the 1136.-Parallel-Courses-Modularity-and-optimizations branch May 12, 2021 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1136. Parallel Courses

3 participants