[leetcode]Merge Sorted Array
2014-04-11 13:17
239 查看
class Solution { public: void merge(int A[], int m, int B[], int n) { // use STL function copy( B, B + n, A + m); sort(A, A + m + n); /** another concrete method ********* //put the num from the tail of array A int index = m+n-1; for(; index>=0; index--) { if(n<=0) { return ; } else if(m<=0) { A[index] = B[--n]; } else if(A[m-1] < B[n-1]) { A[index] = B[--n]; } else { A[index] = A[--m]; } } *********** **/ } };
相关文章推荐
- [LeetCode] Merge Sorted Array
- leetcode: Merge Sorted Array
- LeetCode | Merge Sorted Array
- LeetCode--Merge Sorted Array
- LeetCode: Merge Sorted Array
- 开始刷题leetcode day3:Merge Sorted Array
- [Leetcode]#88 Merge Sorted Array
- leetcode 88 Merge Sorted Array C++
- leetcode笔记:Merge Sorted Array
- LeetCode题解:Merge Sorted Array
- LeetCode-88-Merge Sorted Array(归并)-Easy
- [LeetCode]Merge Sorted Array
- [leetcode]Merge Sorted Array
- LeetCode Merge Sorted Array
- [LeetCode]88 Merge Sorted Array
- 【Leetcode】Merge Sorted Array
- [leetcode]Merge Sorted Array @ Python
- [Leetcode][python]Merge Sorted Array
- Leetcode Merge Sorted Array
- leetcode 88 Merge Sorted Array