摘要: #include #include #include using namespace std; int main() { int a[3] = { 1,3,2}; vectornum(a, a + 3); auto rfirst = num.rbegin(); auto rend = num.rend(); auto p = next(rfirs... 阅读全文
posted @ 2017-05-28 23:43 babyking1 阅读(120) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std; int main() { int a[5] = { 1,2,-1,3,5 }; vectornum(a, a + 5); int tar; cin >> tar; cout << distance(num.begin(), remove(num.be... 阅读全文
posted @ 2017-05-28 22:42 babyking1 阅读(92) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std; int main() { int tar; cin >> tar; int a1[5] = { 1,2,3,-1,0 }; vectornum(a1, a1 + 5); vector > res; sort(num.beg... 阅读全文
posted @ 2017-05-28 22:33 babyking1 阅读(129) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std; int main() { int a[6] = { -1,0,1,2,-1,-4 }; vectornums(a, a + 6); sort(nums.begin(), nums.end()); int tar; cin >> tar; int... 阅读全文
posted @ 2017-05-23 17:29 babyking1 阅读(99) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std; int main() { int a[6] = { -1,0,1,2,-1,-4 }; vectornums(a, a + 6); sort(nums.begin(), nums.end()); int tar; cin >> tar; vec... 阅读全文
posted @ 2017-05-23 17:08 babyking1 阅读(88) 评论(0) 推荐(0) 编辑
摘要: 解法2: 网上炒的跪服: 阅读全文
posted @ 2017-05-23 16:06 babyking1 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 解法2: 阅读全文
posted @ 2017-05-23 15:32 babyking1 阅读(106) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std; //判断两个有序数组的第k个大的数 int dfs(int *a, int m, int *b, int n, int k) { if (m > n)return dfs(b, n, a, m, k); if (m == 0)return b[k - 1]; if (... 阅读全文
posted @ 2017-05-23 14:55 babyking1 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 因为有重复元素,所以不能通过左边边界>=中间边界确定上升序列,所以通过将左边边界>=分解为两个条件,左边边界>中间---认为左边一定升序,左边 A[mid]) { if (A[mid] < target && target <= A[last-1]) first = mid + 1; else last = mid; } else //和中点相等直接++ first++; } return fa... 阅读全文
posted @ 2017-05-23 14:17 babyking1 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 只有一个旋转点,有二分法可以降低复杂度。 二分过后肯定有半边是有序的,我们假设数组是升序的数组,中间有一个旋转点。 解法一: 解法2: 阅读全文
posted @ 2017-05-23 14:11 babyking1 阅读(100) 评论(0) 推荐(0) 编辑