Leetcode 338 Counting Bits
2017-07-02 16:10
351 查看
Leetcode 338 Counting Bits
#include <vector> #include <intrin.h>//__popcnt #include<nmmintrin.h> using namespace std; class Solution { public: vector<int> countBits(int num) { vector<int> bitsNum; for (int i = 0; i <= num; i++){ int count = 0; /*while (i){ i = i &(i - 1); count++; }*/ //__builtin_popcount(i);gcc的内建函数,计算一个32位无符号整数有多少位为1 //count = __popcnt(i);//vs情况下,MSVC count = _mm_popcnt_u32(i); bitsNum.push_back(count);// SSE4 Streaming SIMD Extensions 4, intel处理器继承指令集的一个版本 } return bitsNum; } };
相关文章推荐
- [LeetCode]338 Counting Bits(dp,lowbit)
- leetcode 338 Counting Bits【leetcode新题】 数11,C++
- Leetcode 338 Counting Bits
- leetcode338:Counting Bits(medium)
- [LeetCode338]Counting Bits
- LeetCode 338 -Counting Bits ( JAVA )
- LeetCode 338 Counting Bits
- leetcode 338 : Counting Bits :找规律&位运算
- leetcode338 Counting Bits
- LeetCode 338 Counting Bits(位运算)
- LeetCode 338 Counting Bits
- Leetcode 338 Counting Bits
- LeetCode[338]Counting Bits
- LeetCode 338 Counting Bits (递推)
- leetcode:338. Counting Bits
- leetcode(338). Counting Bits
- leetcode338——Counting Bits
- 位操作-leetcode 338 Counting Bits
- Leetcode 338 Counting Bits
- Leetcode #338 - Counting bits - Medium