Re: [閒聊] 每日LeetCode
沒想到能用布林運算符來解題
以前我一定就直接開map來解
非常好布林
136. Single Number
class Solution {
public:
int singleNumber(vector<int>& nums) {
int ans=0;
for(const int& n:nums){
ans^=n;
}
return ans;
}
};
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.231.154.170 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1707967640.A.382.html
推
02/15 11:28,
1年前
, 1F
02/15 11:28, 1F
→
02/15 11:37,
1年前
, 2F
02/15 11:37, 2F
推
02/15 11:43,
1年前
, 3F
02/15 11:43, 3F
推
02/15 11:52,
1年前
, 4F
02/15 11:52, 4F
討論串 (同標題文章)
完整討論串 (本文為第 679 之 719 篇):