[LintCode] 合并排序数组II
2024-09-20 10:43:22
class Solution {
public:
/**
* @param A: sorted integer array A which has m elements,
* but size of A is m+n
* @param B: sorted integer array B which has n elements
* @return: void
*/
void mergeSortedArray(int A[], int m, int B[], int n) {
// write your code here
int pa = m - , pb = n - , p = m + n - ;
while (pa >= && pb >= ) {
if (A[pa] >= B[pb]) A[p--] = A[pa--];
else A[p--] = B[pb--];
}
while (pb >= ) A[p--] = B[pb--];
}
};
最新文章
- [普通平衡树treap]【学习笔记】
- Java 集合类详解
- codeforces 471C.MUH and House of Cards 解题报告
- javascript第一弹——对象
- C++-理解构造函数、析构函数执行顺序
- check windows return character
- Cocos2d-JS特效
- Flume NG中的Kafka Channel
- 微信小程序,前端大梦想(七)
- pc网页到移动端怎么自动加载适应移动端的css。
- 微信连wifi认证
- printf 函数原型
- Kubernetes学习之路(26)之kubeasz+ansible部署集群
- 多线程-interrupt(),isInterrupted(),interrupted()(转)
- Linux内核配置.config文件
- C3P0连接池使用教程
- 51nod 1682 中位数计数(前缀和)
- Java多线程对同一个对象进行操作
- Java中的平衡树
- eclipse 打开的时候弹出 'Building workspace' has encountered a problem. Errors occurred during