We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
这道题是双周赛第三题。
一开始我也没有头绪,最后观察题目给的第二个用例,用Map存取结果后,发现出现偶数次的数可以用^约去,于是直接得出了结果。
竞赛完后回想,显然,这是要找规律,化简式子的。
所以可以从用例入手,比如题目给出的[1,4],可以发现如下关键线索:
所以最后所有复杂的式子约去,只剩下所有元素本身。
class Solution { public int xorBeauty(int[] nums) { int ans = 0; for (int num : nums) { ans ^= num; } return ans; } }
有意思的位运算。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
这道题是双周赛第三题。
一开始我也没有头绪,最后观察题目给的第二个用例,用Map存取结果后,发现出现偶数次的数可以用^约去,于是直接得出了结果。
竞赛完后回想,显然,这是要找规律,化简式子的。
所以可以从用例入手,比如题目给出的[1,4],可以发现如下关键线索:
所以最后所有复杂的式子约去,只剩下所有元素本身。
有意思的位运算。
The text was updated successfully, but these errors were encountered: