You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * @param {number[]} nums * @return {number} */// var singleNumber = function(nums) {// let ans = 0;// for(const num of nums) {// ans ^= num;// }// return ans;// };varsingleNumber=function(nums){returnnums.reduce((pre,cur)=>{returnpre^cur;},0)}
The text was updated successfully, but these errors were encountered:
136. 只出现一次的数字
Description
Difficulty: 简单
Related Topics: 位运算, 数组
给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。
说明:
你的算法应该具有线性时间复杂度。 你可以不使用额外空间来实现吗?
示例 1:
示例 2:
Solution
Language: JavaScript
The text was updated successfully, but these errors were encountered: