当前位置:网站首页>面试宝典一: 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
边栏推荐
- HAVE FUN | “SOFA 星球”飞船计划、源码解析活动最新进展
- Redis-使用jedis连接linux中redis服务器失败的解决方案
- BGP综合实验
- Switches and routers technologies - 30 - standard acls
- [E-commerce operation] How to formulate a social media marketing strategy?
- [Embedded open source library] The use of cJSON, an efficient and streamlined json parsing library
- Delphi7学习记录-demo实例
- K8s复习笔记7--Redis单机和Redis-cluster的K8S实现
- MyEclipse数据库工具使用教程:使用驱动程序
- paddlepaddle implements CS_CE Loss and incorporates PaddleClas
猜你喜欢
关于ie下href有中文出现RFC 7230 and RFC 3986问题的研究
StarUML使用心得
C statement: data storage
一个月闭关直接面进大厂,这份Android面试笔记是真的牛逼
Sub-database sub-table ShardingSphere-JDBC notes arrangement
Thymeleaf
C语言:实用调试技巧
The use of async (asynchronous) and await
Switches and routers technology - 26 - configure OSPF peripheral area
Idea essential skills to improve work efficiency
随机推荐
form form submission database Chinese becomes a question mark
Redis-数据类型(基本指令、String、List、Set、Hash、ZSet、BitMaps、HyperLogLog、GeoSpatial)/发布和订阅
Some common mysql entry exercises
Switch and Router Technology - 28 - NSSA Areas for OSPF
关于ie下href有中文出现RFC 7230 and RFC 3986问题的研究
玩转mysql之查看mysql版本号
Oracle常用语句归纳_持续更新
【嵌入式开源库】MultiTimer 的使用,一款可无限扩展的软件定时器
分库分表ShardingSphere-JDBC笔记整理
Idea提升工作效率的必备技巧
ARM Architecture 4: Embedded Hardware Platform Interface Development
BitLocker的解密
Win10远程连接(实现多用户同时连接)
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/data/xxxx
Core Data 多线程设计
nodes服务器
IDEA使用记录
Application layer protocol - DNS
宝塔Linux环境下redis开启多端口
K8s复习笔记7--Redis单机和Redis-cluster的K8S实现