测试评估
| 指标 | 结果 |
|---|---|
| Base 测试 | FAIL |
| Plus 测试 | FAIL |
| 代码长度 | 510 字符 |
模型生成的代码 (510 字符)
def largest_subset(nums):
"""
Find the size of the largest subset of numbers such that every pair is divisible.
In such a subset, for any two numbers a and b, either a % b == 0 or b % a == 0.
"""
if not nums:
return 0
# Sort the numbers to ensure that for any pair i < j, nums[i] <= nums[j],
# so we only need to check nums[j] % nums[i] == 0.
nums.sort()
n = len(nums)
# dp[i] = size of the largest divisible subset ending with nums[i]
dp = [1] * n
Base 失败测试用例
[[1, 3, 6, 13, 17, 18]]
Plus 失败测试用例
[[34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584]]