未验证 提交 1b2ec335 编写于 作者: D dragon_li 提交者: GitHub

Update 缺失和重复的元素.md

上级 3360ffda
......@@ -148,7 +148,7 @@ class Solution {
int n = nums.length;
int dup = -1;
for (int i = 0; i < n; i++) {
// 元素是从 1 开始的
// 元素是从 1 开始的
int index = Math.abs(nums[i]) - 1;
// nums[index] 小于 0 则说明重复访问
if (nums[index] < 0)
......@@ -160,7 +160,7 @@ class Solution {
for (int i = 0; i < n; i++)
// nums[i] 大于 0 则说明没有访问
if (nums[i] > 0)
// 将索引转换成元素
// 将索引转换成元素
missing = i + 1;
return new int[]{dup, missing};
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册