二分查找的应用 |
您所在的位置:网站首页 › 二分查找是一个有效计算平方根 › 二分查找的应用 |
程序员面试金典——面试题 05.03. 翻转数位
早点睡吧451: 我觉得你那不对。下面是修改后的。 class Solution { public: int reverseBits(int num) { int bit = 32; int ans = 0; int pre = 0; int ctn = 0; while( bit ){ if( num & 1 ){ ctn++; }else{ ans = max(ans, ctn + pre + 1); pre = ctn; ctn = 0; } num >>= 1; bit--; } ans = max( ans, ctn + pre + 1); if (ans > 32) ans = 32; return ans; } }; 程序员面试金典——面试题 05.03. 翻转数位早点睡吧451: 如果是负数呢? 走台阶问题(递归方法+动态规划)2301_79378972: 听课没听懂在这儿搞懂了 走台阶问题(递归方法+动态规划)happy22lucky: 还是没看懂它是怎么保存相同计算的 LeetCode 506——相对名词(排序+查找)ctotalk: 感谢 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |