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))));
}
};
沒有留言:
張貼留言