
位运算
永远的EMT
每天时刻保持超越自我的意识
展开
-
【LeetCode】136. Single Number
题解:从一个数组从寻找只出现一次的数其他只出现两次,位运算的简单题,直接异或运算即可,相同的两个异或运算为0所以最终留下的是只出现一次的那个数 class Solution { public: int singleNumber(vector<int>& nums) { int ones=0; for(int i:nums){ ...原创 2018-10-14 21:44:22 · 119 阅读 · 0 评论 -
【LeetCode】260. Single Number III
题目: Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note: Your algorithm should have a linear runtime complex...转载 2018-10-15 22:51:34 · 167 阅读 · 0 评论 -
【LeetCode】Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of gr...原创 2018-10-27 23:43:19 · 168 阅读 · 0 评论