上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 14 下一页
摘要: 题目链接:https://leetcode-cn.com/problems/jian-sheng-zi-lcof/ 贪心 class Solution { public: int cuttingRope(int n) { if(n <= 3) return 1 * (n - 1); int res 阅读全文
posted @ 2020-05-08 19:23 NaughtyCoder 阅读(84) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/er-cha-sou-suo-shu-de-hou-xu-bian-li-xu-lie-lcof/ 递归 直接用二叉搜索树的后序遍历构建二叉树(利用二叉搜索树的性质,根节点的左子树都比他小,右子树都比他大),如果构建成功,返 阅读全文
posted @ 2020-05-06 20:36 NaughtyCoder 阅读(117) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/shu-zu-zhong-shu-zi-chu-xian-de-ci-shu-lcof/ 思路 问题简化 考虑一个简单问题:数组中所有数组只有一个数出现了一次,其它数字都出现了两次? 利用异或的性质,两数相同,异或结果为0, 阅读全文
posted @ 2020-05-06 20:32 NaughtyCoder 阅读(112) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/ping-heng-er-cha-shu-lcof/ 递归 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode 阅读全文
posted @ 2020-05-06 20:20 NaughtyCoder 阅读(93) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/er-cha-shu-zhong-he-wei-mou-yi-zhi-de-lu-jing-lcof/ 递归 时间复杂度:O(n) 空间复杂度:O(n) /** * Definition for a binary tree 阅读全文
posted @ 2020-05-06 20:19 NaughtyCoder 阅读(96) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/shu-zu-zhong-de-ni-xu-dui-lcof/ 归并排序 class Solution { public: int merge(vector<int>& nums, int l, int r) { if(l 阅读全文
posted @ 2020-05-04 15:01 NaughtyCoder 阅读(90) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/ 搜索与回溯 class Solution { public: int get_single_sum(int x){ int s = 0; while(x 阅读全文
posted @ 2020-05-04 14:20 NaughtyCoder 阅读(81) 评论(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 word) 阅读全文
posted @ 2020-05-04 13:45 NaughtyCoder 阅读(78) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode cn.com/problems/biao shi shu zhi de zi fu chuan lcof/ 阅读全文
posted @ 2020-05-04 10:41 NaughtyCoder 阅读(87) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/shu-zi-xu-lie-zhong-mou-yi-wei-de-shu-zi-lcof/ 数学 先确定第n位所在的数字是几位数; n - 10 - 90 * 2 - 900 * 3 - 9000 * 4 ... 确定第n 阅读全文
posted @ 2020-05-04 10:37 NaughtyCoder 阅读(116) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 14 下一页