PAT-2019年秋季考试-甲级 7-2 Merging Linked Lists (25 分)

该博客介绍了PAT甲级考试中的一道题目,要求将两个链表进行合并,具体操作是将较短的链表逆置后插入到较长链表中。文章详细解析了题意,并提供了解题思路,包括如何存储链表,判断长度,逆置短链表以及合并链表的步骤。
摘要由CSDN通过智能技术生成

7-2 Merging Linked Lists (25 分)

Given two singly linked lists L1 = a1→a2→⋯→a​n−1→a​n and L​2​ = b​1→b​2→⋯→b​m−1→b​m​ . If n≥2m, you are supposed to reverse and merge the shorter one into the longer one to obtain a list like a1→a2→b​m​→a3→a4→b​m−1⋯. For example, given one list being 6→7 and the other one 1→2→3→4→5, you must output 1→2→7→3→4→6→5.

Input Specification:

Each input file contains one test case. For each case, the first line contains the two addresses of the first nodes of L​1​ and L​2​​ , plus a positive N (≤10​5) which is the total number of nodes given. The address of a node is a 5-digit nonnegative integer, and NULL is represented by <

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值