halfrost/LeetCode-Go

0164.Maximum Gap基数排序中缺少计数器更新导致BUG

pench3r opened this issue · 1 comments

https://github.com/halfrost/LeetCode-Go/blob/master/leetcode/0164.Maximum-Gap/164.%20Maximum%20Gap.go#L69

原代码:

		for i := len(nums) - 1; i >= 0; i-- {
			tmp := count[(nums[i]/exp)%10]
			tmp--
			aux[tmp] = nums[i]
		}

缺少计数器更新,应更新为:

		for i := len(nums) - 1; i >= 0; i-- {
			tmp := count[(nums[i]/exp)%10]
			tmp--
			aux[tmp] = nums[i]
			count[(nums[i]/exp)%10] = tmp
		}

@pench3r 您好,你指出的这里确实是我错了。我回翻了我的提交记录,之前确实是 AC 了,看来测试数据之前还比较弱。我加上了针对这里的测试用例了。一并都更新在代码文件里面了。LeetCode Cookbook 也更新了。谢谢大佬指出错误,非常感谢!🙏🏻