当前位置:网站首页>In situ merging of two arrays with two pointers
In situ merging of two arrays with two pointers
2022-06-30 14:37:00 【Douglas_ LT】
A daily topic ing, Today is a day easy topic 88. Merge Sorted Array
class Solution {
public:
void merge(vector<int>& nums1, int m, vector<int>& nums2, int n)
{
int pos=nums1.size()-1;
int i=m-1,j=n-1;
while(i>=0&&j>=0)
{
int temp=max(nums1[i],nums2[j]);
if(nums1[i]>nums2[j]) i--;
else j--;
nums1[pos]=temp;
pos--;
}
while(j>=0&&pos>=0){
nums1[pos]=nums2[j];
j--;pos--;
}
}
};
边栏推荐
- @Component use cases
- Notepad regular delete the line of the keyword
- 2021-07-15Caused by: org. quartz. ObjectAlreadyExistsException: Unable to store Job : ‘DEFAULT. TASK_ 1‘
- go time. after
- [buuctf] [geek challenge 2019] secret file
- Advanced usage of go language for loop break and continue
- Numpy creates an empty array data = np empty(shape=[1, 64,64,3])
- PS cutting height 1px, Y-axis tiling background image problem
- MFQE 2.0: A New Approach for Multi-FrameQuality Enhancement on Compressed Video
- Three uses of golang underscores
猜你喜欢
Component communication mode
Att & CK red team evaluation field (I)
Solve the error in my QT_ thread_ global_ End(): 3 threads didn't exit
After the MySQL service on the local computer is started and stopped, some services will automatically stop when they are not used by other services or programs
PS tip: the video frame to Layer command cannot be completed because dynamiclink is not available
Crypto questions
XSS challenge (6-10) more detailed answers
PS cutting height 1px, Y-axis tiling background image problem
Getting started with shell Basics
I love network security for new recruitment assessment
随机推荐
remote: Support for password authentication was removed on August 13, 2021. Please use a personal ac
About the problems encountered when using the timer class to stop with a button (why does the QPushButton (for the first time) need to be clicked twice to respond?)
[buuctf] [actf2020 freshman competition]exec1
Small exercise of process and signal
Three ways and differences of defining functions in JS
Realize a simple LAN communication (similar to feiqiu)
Implementation of forwarding server using IO multiplexing
Go language for loop multivariable use
Talk about Vue's two terminal diff algorithm, analysis of the rendering principle of the mobile terminal, and whether the database primary key must be self incremented? What scenarios do not suggest s
V3 01_ Welcome
Why is the resolution of the image generated by PHP GD library 96? How to change it to 72
Jetpack compose for perfect screen fit
Use PHP to delete the specified text content in the file
Use of laravel repository mode
2021-08-05 leetcode notes
Attack and defense world web questions
Add attributes to multimode
NoViableAltException([email protected][])
Google Earth engine (GEE) - ghsl: global human settlements layer, built grid 1975-1990-2000-2015 (p2016) data set
Comprehensively analyze the basic features and summary of free and paid SSH tools