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

剑指 Offer 题解 - 位运算:56. 数组中只出现一次的数字 解题思路描述有误 #1217

Open
justsowoo opened this issue Nov 24, 2022 · 0 comments

Comments

@justsowoo
Copy link

justsowoo commented Nov 24, 2022

解题思路中,第三段部分:

将 diff 作为区分两个元素的依据,一定有一个元素对 diff 进行异或的结果为 0,另一个结果非 0。设不相等的两个元素分别为 z 和 k,遍历数组所有元素,判断元素与 diff 的异或结果是否为 0,

示例答案代码为:

if ((num & diff) == 0)

根据下方的示例代码和牛客官方题解,上方的“异或”应改为“按位与

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

No branches or pull requests

1 participant