当前位置: 首页 > wzjs >正文

网站开发技术历史大连甘井子区地图

网站开发技术历史,大连甘井子区地图,自个网站,科技园一、链表的创建及数据插入 示例代码: #1.定义一个结点类 class ListNode():def __init__(self,x,nextNone):self.valxself.nextnext #2.定义单链表 class LinkList():#2.1 创建一个头指针为空的链表def __init__(self,headNone):self.headNone#2.2 将数据插入链表…

一、链表的创建及数据插入

示例代码:

#1.定义一个结点类
class ListNode():def __init__(self,x,next=None):self.val=xself.next=next
#2.定义单链表
class LinkList():#2.1 创建一个头指针为空的链表def __init__(self,head=None):self.head=None#2.2 将数据插入链表(最后返回链表的头指针)def initList(self,data):#2.3 创建头结点self.head=ListNode(data[0])r=self.headp=self.head#2.4 逐个为data内的数据创建结点,建立链表for i in data[1:]:node=ListNode(i)p.next=nodep=p.nextreturn rdef printList(self,head):if not head:return []node=headwhile node:print(node.val,end='\t')node=node.nextprint()if __name__ == '__main__':l=LinkList()tup1=(1,2,3,4,5)lst1=[6,7,8,9,10]l1=l.initList(tup1)l2=l.initList(lst1)l.printList(l1)l.printList(l2)

运行结果:

二、链表反转

#集合添加元素
# s={1,2,3}  1->2->3  3->2->1
# s.add(4)
# print(s)
class ListNode():def __init__(self,x):self.val=xself.next=None
class Solution():def ReverseList(self,head:ListNode)->ListNode:#处理空链表if not head:return Nonecur=headpre=Nonewhile cur:#断开链表,要记录后续一个temp=cur.next#当前的next指向前一个cur.next=prepre=curcur=tempreturn pre

三、合并两个有序链表

# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param pHead1 ListNode类 
# @param pHead2 ListNode类 
# @return ListNode类
#
class Solution:def Merge(self , pHead1: ListNode, pHead2: ListNode) -> ListNode:# write code herecur0=cur=ListNode(12)while pHead1 and pHead2:if pHead1.val<pHead2.val:cur.next=pHead1pHead1=pHead1.nextcur=cur.nextelse:cur.next=pHead2pHead2=pHead2.nextcur=cur.nextcur.next=pHead1 or pHead2return cur0.next


文章转载自:

http://3aPbDYsn.skrww.cn
http://WzRfYi1K.skrww.cn
http://yxOUwpEn.skrww.cn
http://p7eHuUjV.skrww.cn
http://AMhSocBr.skrww.cn
http://IMsoysBd.skrww.cn
http://i6M7zQVM.skrww.cn
http://F4N7lWVR.skrww.cn
http://LkQecCO1.skrww.cn
http://90lvefLL.skrww.cn
http://vT4WdZbD.skrww.cn
http://hkw0tQiq.skrww.cn
http://AHQCAKAj.skrww.cn
http://9hOmxp1e.skrww.cn
http://pzFgE2PW.skrww.cn
http://imisODdV.skrww.cn
http://u2ci9AMG.skrww.cn
http://6mz3UF7m.skrww.cn
http://K5aS6tUh.skrww.cn
http://b4ylxJLp.skrww.cn
http://sGZSPBaN.skrww.cn
http://nq0rohIB.skrww.cn
http://7mo4dyUa.skrww.cn
http://PsmEDxJL.skrww.cn
http://g85C6r9y.skrww.cn
http://tD0zcscJ.skrww.cn
http://6G8rY8Xi.skrww.cn
http://CJukeztx.skrww.cn
http://oDHHpoBv.skrww.cn
http://gmCFELpH.skrww.cn
http://www.dtcms.com/wzjs/777281.html

相关文章:

  • 网站怎么做缓存上海市城乡住房建设厅网站
  • 瑞华特散热器网站谁给做的推动高质量发展的必要性
  • 关于建设网站的合作合同重庆seo研究中心
  • 网站建设花钱少做网站的内容资源
  • 中山网站建设解决方案做动态效果的网站
  • 公司做网站需要哪些步骤网站怎样关键词排名优化
  • 自己做网站服务器做个营销网站
  • 帮人做兼职的网站吗wordpress管理员手册
  • 如何申请网站备案号手机网站注册
  • 宁波手机网站开发工程建设网站怎么提交
  • 可以做h5的网站网站不想被百度抓取
  • 网站网页建设论文广州市建设工程安监站网站
  • 网站开发设计哪家好爱站网长尾词挖掘
  • 百度小程序对网站seoWordPress中文替换布
  • nginx wordpress 多站点南宁网站建设升上去
  • 网站提交订单付款才跳转怎么做北京最新消息今天新闻
  • 唐山网站托管wordpress例行维护
  • jquery做手机网站网站模板 兼容
  • 哈尔滨做网站优化百度怎么发帖做推广
  • 网站建设网站定制开发wordpress用户头像
  • 一个空间可以绑定几个网站横向网站模板
  • 网站迁移建设方案站长工具查询网站信息
  • 大兴网站开发公司网站建设软文推广
  • 做安卓icon图标下载网站海南的论坛网站建设
  • 深圳电子商务网站制作外贸网站建设560
  • vps搭建vpn无法访问国内网站西部数码网站管理助手4.0 教程
  • 教修图的网站全国广电网络公司排名
  • 网站建设答辩ppt模板网上销售渠道
  • 旅游海外网站建设外贸网站seo推广
  • 婚纱摄影网站的设计与实现温州推广平台