摘要: /* 题目: 求二叉搜索树的第k大节点。 */ /* 思路: 中序遍历。 */ #include<iostream> #include<cstring> #include<vector> #include<algorithm> #include<map> using namespace std; s 阅读全文
posted @ 2019-12-23 22:24 笨宝宝 阅读(241) 评论(0) 推荐(0)
摘要: /* 题目: 求单调递增数组中,数值与下标相等的任意数字。 */ /* 思路: 二分法。 */ #include<iostream> #include<cstring> #include<vector> #include<algorithm> #include<map> using namespac 阅读全文
posted @ 2019-12-23 21:45 笨宝宝 阅读(134) 评论(0) 推荐(0)
摘要: /* 题目: 寻找递增数组0~n-1中缺失的数字。 */ /* 思路: 变形二分法。 */ #include<iostream> #include<cstring> #include<vector> #include<algorithm> #include<map> using namespace 阅读全文
posted @ 2019-12-23 21:33 笨宝宝 阅读(231) 评论(0) 推荐(0)
摘要: /* 题目: 统计一个数字在排序数组中出现的次数。 */ /* 思路: 1、从前往后遍历,时间复杂度O(n)。 2、二分查找到目标数字target,向前向后遍历,时间复杂度O(n)。 3、利用二分法,递归找到数字出现的第一个位置和最后一个位置,时间复杂度O(logn)。 */ #include<io 阅读全文
posted @ 2019-12-23 20:49 笨宝宝 阅读(189) 评论(0) 推荐(0)