/* 自定義代碼塊樣式 */

herrDeng網內搜尋

自訂搜尋

Ads

2025年11月8日 星期六

Py3 C++導出遞迴公式解難題Leetcode1611 Minimum One Bit Operations to Make Integer...


Py3 C++導出遞迴公式解難題Leetcode1611  Minimum One Bit Operations to Make Integers Zero從導出公式到寫出code,一次完成解Leetcode難題
[C++一行解請進]

----
From deriving the formula to writing the code, solve a LeetCode problem in one go.
class Solution {
public:
    int minimumOneBitOperations(int n) {
        return (n==0)? 0: ((1<<(32-countl_zero(unsigned(n))))-1-minimumOneBitOperations(n^bit_floor(unsigned(n))));
    }
};

沒有留言:

Related Posts Plugin for WordPress, Blogger...

熱門文章