当前位置:网站首页>面试宝典一: 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边栏推荐
- The use of async (asynchronous) and await
- How to switch Green Shield encryption to IP-Guard encryption smoothly
- 2022年质量员-土建方向-通用基础(质量员)考试模拟100题及在线模拟考试
- Win10远程连接(实现多用户同时连接)
- Golden Warehouse Database KingbaseGIS User Manual (6.10. Geometric Object Operation Operator)
- Switch and Router Technology-29-OSPF Virtual Link
- Thymeleaf
- C语言:实用调试技巧
- 元宇宙社交应用,靠什么吸引用户「为爱发电」?
- MySQL存储引擎概念
猜你喜欢

一个月闭关直接面进大厂,这份Android面试笔记是真的牛逼

2022年Android面试中最常问的问题是什么?

【嵌入式开源库】MultiTimer 的使用,一款可无限扩展的软件定时器
![ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/data/xxxx](/img/02/3896b29a955ae84a0f0326f0d2cabf.png)
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/data/xxxx

redis连接idea

IDEA模板总结

Switch and Router Technology - 32 - Named ACL

CentOS7静默安装Oracle11g_转载

Delphi7学习记录-demo实例

Redis详解
随机推荐
Switches and routers technology - 24 - configure OSPF single area
Zabbix builds enterprise-level monitoring and alarm platform
LeetCode刷题Top100之两数之和
Switch and Router Technology-27-OSPF Route Redistribution
Switch and Router Technology-31-Extended ACL
[No 2022 Shanghai Security Officer A Certificate Exam Question Bank and Mock Exam
Sub-database sub-table ShardingSphere-JDBC notes arrangement
Switches and routers technology - 26 - configure OSPF peripheral area
群晖DS220+ 应用小笔记
Redis details
普林斯顿微积分读本05第四章--求解多项式的极限问题
form form submission database Chinese becomes a question mark
什么是三次握手和四次挥手(清晰易懂)
每周推荐短视频:你常用的拍立淘,它的前身原来是这样的!
FPGA engineer interview questions collection 121~130
【嵌入式开源库】MultiTimer 的使用,一款可无限扩展的软件定时器
Switch and Router Technology-35-NAT to PAT
Switch and Router Technology - 22/23 - OSPF Dynamic Routing Protocol/Link State Synchronization Process
Mysql入门练习
C语句:数据存储