提供三種位元處理方式來數位元,第三個解感謝由網友@Adamm93提供。提供 O(n) 線性時間解決方案。 __builtin_popcount 或 C++ bitset count() 執行時間為 O(log n) ,其實就是真的去數,因此在快速實作不使用。
[codes on Leetcode] https://leetcode.com/problems/counting-bits/solutions/3986169/easy-c-python-bit-manipulations-welcome-for-tricks/
-------
3 bit processing methods are provided , and the third solution is provided by @Adamm93. Provide all O(n) linear time solutions. The execution time of __builtin_popcount or C++ bitset count() is O(log n), which is actually counting, so it is not used in fast implementation.
沒有留言:
張貼留言