当前位置:网站首页>2个有序数组排序
2个有序数组排序
2022-08-09 13:07:00 【论一个测试的养成】
def yxsort(l1,l2):
while True:
try:
l1_f = l1[0]
except:
return l2
try:
l2_f = l2[0]
except:
return l1
l2_e = l2[-1]
l1_e = l1[-1]
if l1_e <= l2_f:
l1.extend(l2)
return l1
if l2_e <= l1_f:
l2.extend(l1)
return l2
if l1_e > l2_f:
sort(l2,l1,l1_e)
# for i,j in enumerate(l2):
# if l1_e <= j :
# l1.remove(l1_e)
# l2.insert(i,l1_e)
# break
if l2_e > l1_f:
sort(l1,l2,l2_e)
def sort(l1,l2,data):
for i,j in enumerate(l1):
if data <= j:
l2.remove(data)
l1.insert(i,data)
break
if __name__ == '__main__':
l2 = [1, 2, 3, 4, 5, 6]
l1 = [3, 4, 5, 6, 7, 8]
l3 = [1, 2, 3, 5, 7, 9]
l4 = [3, 4, 5, 6, 7, 8]
x = yxsort(l2,l1)
print(x)
边栏推荐
猜你喜欢
神经网络与深度学习(TensorFlow)
pytest 之 fixture的定义及作用域
企业公众号开通微信支付
RobotFramework简介
GIN中GET POST PUT DELETE请求
Anta and Huawei Sports Health jointly verify the champion running shoes and lead Chinese sports with innovation
kustomize entry example and basic syntax instructions
pytest 之 fixture的调用
[MRCTF2020]套娃-1
七夕力扣刷不停,343. 整数拆分(剑指 Offer 14- I. 剪绳子、剑指 Offer 14- II. 剪绳子 II)
随机推荐
pytest 之 fixture的定义及作用域
FFmpeg相机花屏花图问题解决方法
CPU-MIPS32 instruction architecture (unlocked pipeline microprocessor)
GIN文件上传与返回
昇腾AI开发者创享日南京站!一起CANN机器狗+AI机械臂实现硬核智慧救援!燃爆现场~
Sandbox中的进程/线程相关-1
NC193 二叉树的前序遍历
JS轮播图实现
Record the system calls and C library functions used in this project-2
Q_04_06 把它放在一起:传送
WPF 系统托盘 图标闪烁
IDEA Gradle 常遇问题(二)(持续更新)
Realization of RTSP Protocol
kustomize entry example and basic syntax instructions
Deep Learning Based on R Language - Simple Regression Case
剑指offer,剪绳子2
海康设备获取YV12图像-不用rtsp
01_iTween_第一天--小球抛物线
GIN初探,环境安装
NC40 链表相加(二)