Conversation
|
Your solution for the town judge problem is excellent. It correctly implements the required logic with optimal time and space complexity. The code is clean and well-commented. However, note that the problem you solved in TownJudge.java is different from TheMaze.java. Make sure to submit the correct file for the correct problem. Also, in the TownJudge solution, you might consider adding a check for n=1 (if n==1, then the judge is person 1) but your code already handles that because for n=1, the indegrees array will have size 2, and you check from index 1 to n. Since there are no trust relationships, indegrees[1] will be 0, which is not n-1 (which is 0) so it would return 1? Wait, let me check: for n=1, we need to return 1. But in your code, if there are no trust relationships, the indegrees array is initialized to zeros. Then you iterate from i=1 to n (which is 1). indegrees[1] is 0, but n-1 is 0. So it returns 1. So it is correct. So no change is needed. One minor point: in the for-loop condition, you have Overall, great job! |
No description provided.