摘要: 链接:https://leetcode-cn.com/problems/er-jin-zhi-zhong-1de-ge-shu-lcof/submissions/ 代码: class Solution { public: int hammingWeight(uint32_t n) { int s = 阅读全文
posted @ 2020-02-20 20:48 景云ⁿ 阅读(96) 评论(0) 推荐(0)
摘要: 链接:https://leetcode-cn.com/problems/jian-sheng-zi-ii-lcof/ 代码: class Solution { public: int cuttingRope(int n) { if(n < 4) return n - 1; long res = 1; 阅读全文
posted @ 2020-02-20 20:38 景云ⁿ 阅读(232) 评论(0) 推荐(0)
摘要: 链接:https://leetcode-cn.com/problems/jian-sheng-zi-lcof/ 思路: 1.假设ni >= 5, 3 * (ni - 3) >= ni ? 3ni - 9 >= ni ? 2ni >= 9 2.ni = 4, 4 = 2 * 2 3.2 * 2 * 2 阅读全文
posted @ 2020-02-19 16:19 景云ⁿ 阅读(107) 评论(0) 推荐(0)
摘要: 链接:https://leetcode-cn.com/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/ 思路: dfs 代码: class Solution { public: int get_single_sum(int x) { int s= 0; whi 阅读全文
posted @ 2020-02-19 15:45 景云ⁿ 阅读(153) 评论(0) 推荐(0)
摘要: 链接:https://leetcode-cn.com/problems/ju-zhen-zhong-de-lu-jing-lcof/ 思路: dfs 代码: class Solution { public: bool exist(vector<vector<char>>& board, string 阅读全文
posted @ 2020-02-18 18:25 景云ⁿ 阅读(133) 评论(0) 推荐(0)
摘要: 链接:https://leetcode-cn.com/problems/xuan-zhuan-shu-zu-de-zui-xiao-shu-zi-lcof/submissions/ 思路: 二分 代码: class Solution { public: int minArray(vector<int 阅读全文
posted @ 2020-02-18 18:13 景云ⁿ 阅读(121) 评论(0) 推荐(0)
摘要: 链接:https://leetcode-cn.com/problems/qing-wa-tiao-tai-jie-wen-ti-lcof/ 代码: class Solution { public: int numWays(int n) { std::vector<int> vec = {1, 1}; 阅读全文
posted @ 2020-02-17 16:57 景云ⁿ 阅读(98) 评论(0) 推荐(0)
摘要: 链接:https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof/ 代码: class Solution { public: int fib(int n) { std::vector<int> vec = {0, 1}; for(int i  阅读全文
posted @ 2020-02-17 16:50 景云ⁿ 阅读(74) 评论(0) 推荐(0)
摘要: 链接:https://leetcode-cn.com/problems/zhong-jian-er-cha-shu-lcof/ 思路: 使用map存储中序遍历各节点对应的下标,整个算法使用深搜思想,主要是确定各边界。k 为根结点对应的下标。 dfs左子树:前序:(pl + 1, pl + k - i 阅读全文
posted @ 2020-02-16 16:05 景云ⁿ 阅读(66) 评论(0) 推荐(0)
摘要: 链接:https://leetcode-cn.com/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/ 代码: class CQueue { public: stack<int> stack_a; stack<int> stack_b; CQueu 阅读全文
posted @ 2020-02-16 15:18 景云ⁿ 阅读(73) 评论(0) 推荐(0)