網頁

2026年2月21日 星期六

C++ Py3 bitmask速解Leetcode 762 Prime Number of Set Bits in Binary Representation


C++ Py3 bitmask速解Leetcode 762  Prime Number of Set Bits in Binary Representation
這段影片示範如何使用計數位元和位元遮罩(bit mask),用幾行程式碼解決這個問題。
-----
this video shows how to use count bits & bitmask to solve this question in few lines. 

2026年2月19日 星期四

Py3 C++迴圈與計數解Leetcode 696 Count Binary Substrings


Py3 C++迴圈與計數解Leetcode 696  Count Binary Substrings
Leetcode 696. Count Binary Substrings雖然標示為easy,也沒那麼trivial,花了一番功夫才解出branchless C++。而一般回圈解倒是不難,但須要思考一下
-----
Leetcode 696. Count Binary Substrings, though marked as easy, isn't exactly trivial; it took me some effort to solve it in branchless C++. Solving the general loop problem isn't difficult, but it needs thinking.