国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Leetcode 136. Single Number

2019-11-14 09:54:31
字體:
來源:轉載
供稿:網友

Given an array of integers, every element appears twice except for one. Find that single one.

Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

s思路: 1. 這道題遇到過! 不用內存,那就是一直做xor運算,相同的數xor等于0,最后只剩下the single number. 2. 這道題就是利用兩個數異或的性質,基本也就是一道數學題!

class Solution {public: int singleNumber(vector<int>& nums) { int res=0; for(int i=0;i<nums.size();i++){ res^=nums[i]; } return res; }};
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 萨迦县| 桑日县| 仁布县| 朝阳市| 陆川县| 广汉市| 泰州市| 彰武县| 万源市| 临洮县| 江油市| 内江市| 平远县| 苏尼特左旗| 定陶县| 陵水| 馆陶县| 兴化市| 合作市| 舟曲县| 金门县| 嫩江县| 隆安县| 蒙城县| 永胜县| 霍林郭勒市| 毕节市| 武清区| 鸡西市| 临邑县| 平潭县| 竹溪县| 姜堰市| 石阡县| 咸宁市| 祁连县| 兴化市| 新巴尔虎右旗| 阆中市| 南开区| 太原市|