当前位置:网站首页>面试宝典一: code题目记录
面试宝典一: code题目记录
2022-08-11 05:13:00 【甜辣uu】
两个有序链表合并问题
描述
输入两个递增的链表,单个链表的长度为n,合并这两个链表并使新链表中的节点仍然是递增排序的。
数据范围: 0 \le n \le 10000≤n≤1000,-1000 \le 节点值 \le 1000−1000≤节点值≤1000
要求:空间复杂度 O(1)O(1),时间复杂度 O(n)O(n)
如输入{1,3,5},{2,4,6}时,合并后的链表为{1,2,3,4,5,6},所以对应的输出为{1,2,3,4,5,6},转换过程如下图所示:
class ListNode():
def __init__(self,x,nex=None):
self.val = x
self.next = nex
ListNode=ListNode(1,ListNode(2,ListNode(3,ListNode(4,ListNode(5,None)))))
while ListNode :
print(ListNode
边栏推荐
- Switches and routers technology - 21 - RIP routing protocol
- Use Adobe genuine software for prostitution to reduce the slow employment and non-employment of fresh graduates
- BGP综合实验
- Four functional interfaces
- 代码在线审查(添加网页批注)的实现
- 元宇宙社交应用,靠什么吸引用户「为爱发电」?
- MFC Interprocess Communication (Shared Memory)
- Difference between @Resource and @Autowired
- Mysql入门练习
- Unity WebGL RuntimeError: integer overflow(整数溢出问题)
猜你喜欢
3 模块二:科研工具使用
阿里云无法远程连接数据库MySQL错误码10060解决办法_转载
Linux中安装redis
【嵌入式开源库】MultiButton的使用,简单易用的事件驱动型按键驱动模块
Use Adobe genuine software for prostitution to reduce the slow employment and non-employment of fresh graduates
Idea essential skills to improve work efficiency
Paper Notes: Bag of Tricks for Long-Tailed Visual Recognition with Deep Convolutional Neural Networks
【嵌入式开源库】MultiTimer 的使用,一款可无限扩展的软件定时器
MySQL必知必会(初级篇)
Idea 2021.3.3版本文件目录展开
随机推荐
Apache Commons OGNL语法说明_翻译
Switch and Router Technology-31-Extended ACL
Idea 2021.3.3版本文件目录展开
Redis中RDB和AOF的区别
paddlepaddle implements CS_CE Loss and incorporates PaddleClas
什么是三次握手和四次挥手(清晰易懂)
Prometheus :(一)基本概念
Application layer protocol - DNS
3 Module 2: Use of scientific research tools
BGP综合实验
redis连接idea
Let's talk programming languages together
宝塔Linux环境下redis开启多端口
JedisLock_Redis分布式锁实现_转载
Paper Notes: BBN: Bilateral-Branch Network with Cumulative Learning for Long-Tailed Visual Recognition
网络协议1
Switch and Router Technology-27-OSPF Route Redistribution
Redis-数据类型(基本指令、String、List、Set、Hash、ZSet、BitMaps、HyperLogLog、GeoSpatial)/发布和订阅
02. Fold hidden text
IDEA使用记录