1 Star 9 Fork 2

Mancuoj/408-ds

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
11.cpp 539 Bytes
一键复制 编辑 原始数据 按行查看 历史
Mancuoj 提交于 3年前 . feat: 11
#include "ds.h"
/**
* 要求找到两个等长有序序列合并后的中位数,那暴力解就直接合并呗
* 但你会发现并不需要合并全部,我们只需要中间位置的一个值即可
* 所以 mid 就是 len-1,我们按照常规合并有序序列的方法,只移动指针即可
*/
int find_mid(int A[], int B[], int len) {
int i = 0, j = 0;
while (i + j < len - 1) {
if (A[i] <= B[j]) {
i++;
} else {
j++;
}
}
return A[i] <= B[j] ? A[i] : B[j];
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/mancuojie/408-ds.git
git@gitee.com:mancuojie/408-ds.git
mancuojie
408-ds
408-ds
main

搜索帮助