zoukankan      html  css  js  c++  java
  • 21. Merge Two Sorted Lists (python)


    Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.

    Example:

    Input: 1->2->4, 1->3->4
    Output: 1->1->2->3->4->4

    利用链表的思想,先创建个空链表p,用于存放比较后的结果。然后对传入的两个链表进行比较。小的放在空链表中。然后返回创建的链表。

    主函数主要是用于测试Solution函数能不能正常运行。先创建两个列表,然后创建两个指针。调用函数,遍历输出Solution函数传回来的链表。


    
    
    苟有恒,何必三更眠五更起;最无益,莫过一日暴十日寒。
  • 相关阅读:
    学习记录18
    学习记录17
    学习记录16
    小白的心酸连网历程
    学习记录15
    学习记录14
    学习记录13
    学习记录12
    学习记录10
    语法糖
  • 原文地址:https://www.cnblogs.com/shaer/p/9623752.html
Copyright © 2011-2022 走看看