Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
2023120250-裴基旭
修改的思路:
在本次提交中,我解决了判断是否可以将 n 个人分成两组的问题,并修复了代码中的几个错误。具体修改内容如下:
unit
方法)和路径压缩(findFa
方法)的逻辑,以优化算法的性能,避免了递归深度过深的问题。StackOverflowError
和AssertionError
问题,确保代码可以在合理的时间内处理较大的输入。JUnit
测试用例,覆盖了possibleBipartition
、unit
、isconnect
、findFa
等方法,确保每个方法的逻辑正确。此修改能够正确判断是否能够将所有人分配到两个组中,并且通过了所有边界条件和特例测试。