惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园_首页
量子位
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG
D
DataBreaches.Net
B
Blog
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
博客园 - 三生石上(FineUI控件)
爱范儿
爱范儿
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
aimingoo的专栏
aimingoo的专栏
B
Blog RSS Feed
H
Help Net Security
The Cloudflare Blog
U
Unit 42

博客园 - GwQ

微软面试智力题(5) 微软面试智力题(4) 微软面试智力题(3) 微软面试智力题(2) 微软面试智力题(1) 微软面试技术题(0) 微软面试技术题(5) 微软面试技术题(4) 微软面试技术题(22) 微软面试技术题(21) 微软面试技术题(20) 微软面试技术题(19) 微软面试技术题(18) 微软面试技术题(16) 微软面试技术题(15) 微软面试技术题(14) 微软面试技术题(13) 微软面试技术题(12) 微软面试技术题(11)
微软面试技术题(17)
GwQ · 2006-06-17 · via 博客园 - GwQ

两个链表,一升一降。合并为一个升序链表。

 1 List merge(List a, List d) {
 2     List a1 = reverse(d);
 3     List p  =  q  =   new  List();
 4      while  ( a  &&  a1 )  {
 5          if (a.value < a1.value) {
 6             p.next = a;
 7             a = a.next;
 8         }
  else   {
 9             p.next = a1;
10             a1 = a1.next;
11         }

12         p = p.next;
13     }

14      if (a) p.next  =  a;
15     elseif(a1) p.next = a1;
16      return  q.next;
17 }

不知道这道题朋友们有什么更好的方法?

posted on 2006-06-17 08:52  GwQ  阅读(777)  评论(4)    收藏  举报