当前位置:网站首页>[C topic] Li Kou 88. merge two ordered arrays
[C topic] Li Kou 88. merge two ordered arrays
2022-07-25 14:50:00 【GLC8866】
Ideas : Compare nums1 and nums2 The size of the last element of two arrays , Elements with large values are assigned to nums1 Last empty bit of array , Repeat the above operation , until nums2 All elements in the array are assigned to nums1 End the program after .
void merge(int* nums1, int nums1Size, int m, int* nums2, int nums2Size, int n)
{
int m1=m-1;
int n1=n-1;
int mn1=nums1Size-1;
while(n1>=0&&m1>=0)// Enter the loop when there are elements in both arrays
{
if(nums1[m1]>nums2[n1])
{
nums1[mn1]=nums1[m1];
mn1--;
m1--;
}
else
{
nums1[mn1]=nums2[n1];
mn1--;
n1--;
}
}
while(n1>=0)//nums2 When the array has elements that have not been assigned, it enters the loop
{
nums1[mn1--]=nums2[n1--];
}
}边栏推荐
- (原创)自定义一个滚屏的RecyclerView
- Ten common application scenarios of redis
- Jmeter的随机数函数怎么用
- 苹果官网产品打折 买iPhone 13 Pro Max 可省600元
- L1和L2正则化
- SQL优化的一些建议,希望可以帮到和我一样被SQL折磨的你
- thymeleaf通过样式控制display是否显示
- MySQL 45 talks about | 06 global locks and table locks: Why are there so many obstacles to adding a field to a table?
- The security market has entered a trillion era, and the security B2B online mall platform has been accurately connected to deepen the enterprise development path
- QT connect, signal, slot and lambda comparison
猜你喜欢
![Application practice: Great integrator of the paddy classification model [paddlehub, finetune, prompt]](/img/b6/62a346174bfa63fe352f9ef7596bfc.png)
Application practice: Great integrator of the paddy classification model [paddlehub, finetune, prompt]

45padding won't open the box

006操作符简介

Overview of cloud security technology development

Melodic + Realsense D435i 配置及错误问题解决

sudo rosdep init Error ROS安装问题解决方案

Ssh server rejected password

32 use of chrome debugging tools

English语法_不定代词 - other / another

SQL优化的一些建议,希望可以帮到和我一样被SQL折磨的你
随机推荐
51单片机学习笔记(2)
QT connect, signal, slot and lambda comparison
The solution to the problem that the progress bar of ros2 installation connext RMW is stuck at 13%
IP地址分类,判断一个网段是子网超网
Log4j2 basic configuration
Filters get the data in data; Filters use data in data
Polymorphism and interface
Live classroom system 05 background management system
阿里云技术专家邓青琳:云上跨可用区容灾和异地多活最佳实践
PS制作加载GIF图片教程
云安全技术发展综述
Melodic + Realsense D435i 配置及错误问题解决
H5页面input输入框弹起数字键盘,需要支持小数点
(original) customize a scrolling recyclerview
Jqgrid select all cancel single line click cancel event
39 simple version of millet sidebar exercise
thymeleaf设置disabled
Application practice: Great integrator of the paddy classification model [paddlehub, finetune, prompt]
国联证券买股票开户安全吗?
OverTheWire-Natas