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

哪里有网站建设联系方式手机怎么建自己的网站

哪里有网站建设联系方式,手机怎么建自己的网站,新疆人事考试中心,趣php网站开发实战代码单链表是一种链式存取的数据结构,用一组地址任意的存储单元存放线性表中的数据元素。链表中的数据是以结点来表示的,每个结点的构成:元素(数据元素的映象) 指针(指示后继元素存储位置),元素就是存储数据的存储单元,指…

单链表是一种链式存取的数据结构,用一组地址任意的存储单元存放线性表中的数据元素。链表中的数据是以结点来表示的,每个结点的构成:元素(数据元素的映象) + 指针(指示后继元素存储位置),元素就是存储数据的存储单元,指针就是连接每个结点的地址数据。


链表分类:
1.单向或双向
2.带头和不带头
3.循环或非循环

单链表的定义
class ListNode(object):
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next
class NodeList(object):
    def __init__(self):
        self.head = Node()
    def getLen(self):
        if !self.head:
            return 0
        num = 1
        while !cur.next:
            num += 1
            cur = cur.next
        return num
    #打印链表
    def printList(self):
        if !self.head:
            print("none")
        ans = []
        cur = self.head
        while !cur:
            ans.append(curl.val)
            cur = cur.next
        return ans
    #指定位置后面插入
    def insert(self,value,index=-1):
        #如果链表为空,插入第一个元素
        if !self.head:
            self.head = Node(value)
            if index!=-1 or index!=0:
                return False
            return True
        #若指定插入位置为第一位
        if index == 0:
            cur = Node(value)
            cur.next = self.head
            self.head = cur
            return True
        #若指定位置为链表尾
        elif index == -1:
            cur = self.head
            while cur.next:
                cur = cur.next
            cur.next = Node(value)
        else:
            #index从0开始,到index-1的位置,需要移动index-1次
            i = index -1
            cur = self.head
            while i>0 and !cur.next:
                i -= 1
                cur = cur.next
            if !cur.next and i == 0:
                tmp = cur.next
                cur.next = Node(value)
                cur = cur.next
                cur.next = tmp
            #插入位置为链表尾
            elif i == 0 and !cur.next:
                cur.next = Node(value)
            else:
                return "insert index is too large"
            return self.head
    #指定位置后面删除
    def pop(self,value,index=-1):
        if !self.head:
            return False
        elif !self.head.next:
            if self.head.val != value:
                return False
            else:
                self.head = None
                return True
        else:
            cur ,pre = self.head,None
            while cur:
                if cur.val == value:
                    if cur == self.head:
                        self.head = cur.next
                    else:
                        pre.next = cur.next
                    break
                 else:
                    pre ,cur = cur,cur.next
            return True

Leetcode刷题

反转整个链表(面试高频考点)- - 力扣(LeetCode)206
回文链表(数组反转ans[::-1]). - 力扣(LeetCode)234
环形链表(快慢指针). - 力扣(LeetCode)141、142
链表排序148
合并K个升序链表. - 力扣(LeetCode)23
链表每K个节点翻转. - 力扣(LeetCode)24、. - 力扣(LeetCode)25
深拷贝. - 力扣(LeetCode)138
移除链表元素. - 力扣(LeetCode)19、

http://www.hkea.cn/news/767118/

相关文章:

  • 哪里有网站设计公司长沙网络公司最新消息
  • 试描述一下网站建设的基本流程百度怎么发布短视频
  • 我现在有域名怎么做网站搜索关键词热度
  • 海外如何 淘宝网站建设快速seo整站优化排行
  • 代还信用卡网站建设赣州seo顾问
  • 响应式网站建设推广开网店
  • 成都专业网站推广公司优化大师优化项目有
  • 怎么用wordpress搭建网站百度关键词排名点
  • 外挂网站模板域名搜索引擎入口
  • 手机网站开发 pdfseo搜索引擎优化工作内容
  • 上海中小网站建设洛阳seo博客
  • 南宁网站建设公司哪家专业搜索引擎优化包括
  • 新疆住房与建设厅网站新产品推广方式有哪些
  • 做网站站怎么赚钱网络营销模式有哪些?
  • 南通城市建设集团有限公司网站南京谷歌推广
  • 南通网站定制方案怎么查找关键词排名
  • 权大师的网站是哪个公司做的百度做个人简介多少钱
  • 烟台网站建设设计软文广告经典案例100字
  • 做微信用什么网站广州百度seo代理
  • 网站建设目标 优帮云跨境电商营销推广
  • 郑州华恩科技做网站怎么样竞价排名适合百度吗
  • flask做大型网站开发深圳seo博客
  • 合肥网站建设平台小程序怎么引流推广
  • 做网站被拘留免费找客源软件
  • 门户型网站建设百度seo快速提升排名
  • 印度做杂质的网站如何进行网络推广
  • 建设厅八大员兴安盟新百度县seo快速排名
  • 南京网站建设索q.479185700小说排行榜百度
  • 幼儿做爰网站seo工程师是什么职业
  • 申请空间 建立网站吗西安百度推广运营