Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution4 #371

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Solution4 #371

wants to merge 1 commit into from

Conversation

Gaozl9515
Copy link

学号:2023120242

修改内容:

  1. 修复 maximumGap 方法

    • 在原有代码中,基数排序的实现存在错误,未正确处理数字的排序,导致最终结果不正确。修复了排序逻辑,确保基数排序正确实现。
    • 修改了 exp 的更新方式,从 exp += 10 改为 exp *= 10,以确保基数排序按位进行。
    • 修复了遍历数组的方式,修正了 maximumGap 方法的返回值计算,保证它正确计算排序后的相邻元素的最大差值。
  2. 增加测试用例

    • 完善了测试类 L2023120242_4_Test,增加了多个边界和常规场景的测试用例,确保代码的正确性和稳定性。
    • 添加了以下测试方法:
      • testMaximumGapWithValidArray:验证正常数组的最大差值。
      • testMaximumGapWithSingleElement:验证只有一个元素的数组(无差值)。
      • testMaximumGapWithEmptyArray:验证空数组(无差值)。
      • testMaximumGapWithLargeNumbers:验证数组中包含极大差值的情况。

@Boeing747x
Copy link

代码修复得很完善!

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.

2 participants