当前位置: 首页>>代码示例>>Python>>正文


Python ListNode.next方法代码示例

本文整理汇总了Python中ListNode.ListNode.next方法的典型用法代码示例。如果您正苦于以下问题:Python ListNode.next方法的具体用法?Python ListNode.next怎么用?Python ListNode.next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListNode.ListNode的用法示例。


在下文中一共展示了ListNode.next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate_test_list3

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
def generate_test_list3():
    n1 = ListNode(1)
    n2 = ListNode(2)
    n3 = ListNode(3)

    n1.next = n2
    n2.next = n3

    return n1
开发者ID:victorfei,项目名称:interview,代码行数:11,代码来源:rotateList.py

示例2: test2

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
def test2():
    n1a = ListNode(1)
    n1b = ListNode(1)
    n1c = ListNode(1)

    n1a.next = n1b
    n1b.next = n1c
    rslt = removeElement(n1a, 1)
    print(ListNode.print_ll(rslt))
开发者ID:victorfei,项目名称:interview,代码行数:11,代码来源:removeElement.py

示例3: test2

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
def test2():
    n1 = ListNode(1)
    n2 = ListNode(2)
    n3 = ListNode(3)
    n4 = ListNode(4)

    n1.next = n2
    n2.next = n3
    n3.next = n4

    ListNode.print_ll(reorderList(n1))
开发者ID:victorfei,项目名称:interview,代码行数:13,代码来源:reorderList.py

示例4: test2

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
def test2():
    n1 = ListNode(1)
    n2 = ListNode(2)
    n3 = ListNode(3)

    n3.next = n2
    n2.next = n1

    h = n3
    rslt = mergeSort(h)
    ListNode.print_ll(rslt)
开发者ID:victorfei,项目名称:interview,代码行数:13,代码来源:sortList.py

示例5: test3

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
def test3():
    n6 = ListNode(6)
    n7 = ListNode(7)
    n9 = ListNode(9)

    n5 = ListNode(5)

    n6.next = n7
    n7.next = n9
    ListNode.print_ll(addTwoNumbers(n6, n5, 0))
    ListNode.print_ll(addTwoNumbersNoCarry(n6, n5))
开发者ID:victorfei,项目名称:interview,代码行数:13,代码来源:addTwoNums.py

示例6: test2

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
def test2():
    n1 = ListNode(1)
    n2 = ListNode(2)
    n3 = ListNode(3)
    n4 = ListNode(4)

    n1.next = n2
    n2.next = n3
    n3.next = n4

    print(findCycleNode(n1))
开发者ID:victorfei,项目名称:interview,代码行数:13,代码来源:findNodeCycle.py

示例7: test1

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
def test1():
    n0 = ListNode(0)
    n1 = ListNode(1)
    n2 = ListNode(2)
    n3 = ListNode(3)
    n4 = ListNode(4)

    n0.next = n1
    n1.next = n2
    n2.next = n3
    n3.next = n4

    ListNode.print_ll(reorderList(n0))
开发者ID:victorfei,项目名称:interview,代码行数:15,代码来源:reorderList.py

示例8: generate_test_list1

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
def generate_test_list1():
    n1 = ListNode(1)
    n2 = ListNode(2)
    n3 = ListNode(3)
    n4 = ListNode(4)
    n5 = ListNode(5)

    n1.next = n2
    n2.next = n3
    n3.next = n4
    n4.next = n5

    return n1
开发者ID:victorfei,项目名称:interview,代码行数:15,代码来源:rotateList.py

示例9: test3

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
def test3():
    n1  = ListNode(1)
    n1a = ListNode(1)
    n1b = ListNode(1)
    n2a  = ListNode(2)
    n2b  = ListNode(2)

    n1.next = n1a
    n1a.next = n1b
    n1b.next = n2a
    n2a.next = n2b

    ListNode.print_ll(removeDupComp(n1))
开发者ID:victorfei,项目名称:interview,代码行数:15,代码来源:removeDuplicatesCompletely.py

示例10: test2

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
def test2():
    n1  = ListNode(1)
    n1a = ListNode(1)
    n1b = ListNode(1)
    n2  = ListNode(2)
    n3  = ListNode(3)

    n1.next = n1a
    n1a.next = n1b
    n1b.next = n2
    n2.next = n3

    ListNode.print_ll(removeDupComp(n1))
开发者ID:victorfei,项目名称:interview,代码行数:15,代码来源:removeDuplicatesCompletely.py

示例11: partition

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
 def partition(self, head, x):
     """
     :type head: ListNode
     :type x: int
     :rtype: ListNode
     """
     
     if not head:
         return head
             
     # maintain the tail of sub-list with (nodes <= target)
     tail = ListNode(0)
     tail.next = head
     dummy = tail # record it
     
     currentPrev = tail
     current = head
     
     # two operation: 1. cut smaller node; 2. insert to sublist
     while current:
         
         '''
         @note:@memorize:
         下面的反人类解法我也给自己跪了,找到比x小的,插入。
         一直维护小于x的sublist的tail,被main里的测试fail
         
         其实,维护大于等于x的sublit的head,要更加简单,符合人类思维。。。
         '''
         
         if current.val < x: # update tail pointer, but do nothing
             
             # 1. cut
             currentPrev.next = current.next
             currentForNextLoop = current.next # record it first
             
             # 2. insert
             tmp = tail.next
             tail.next = current
             current.next = tmp
             
             tail = current # update smaller-node-list tail
             current = currentForNextLoop # for next loop
             
             # @note: here, no update for currentPrev, still the same one
             
         else:
             currentPrev = current
             current =  current.next
         
     return dummy.next
开发者ID:keypointt,项目名称:leetcode,代码行数:52,代码来源:Partition_List.py

示例12: test4

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
def test4():
    l1 = ListNode(1)
    l2 = ListNode(2)
    l3 = ListNode(3)
    l4 = ListNode(4)
    l5 = ListNode(5)

    l1.next = l2
    l2.next = l3
    l3.next = l4
    l4.next = l5

    ListNode.print_ll(l1)
    ListNode.print_ll(removeNtoLast(l1, 2))
开发者ID:victorfei,项目名称:interview,代码行数:16,代码来源:removeNToLast.py

示例13: test3

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
def test3():
    n1 = ListNode(1)
    n2 = ListNode(2)
    n3 = ListNode(3)
    n4 = ListNode(4)
    n5 = ListNode(5)
    n6 = ListNode(6)

    n1.next = n2
    n2.next = n3
    n3.next = n4
    n4.next = n5
    n5.next = n6
    ListNode.print_ll(revKGrp(n1, 4))
开发者ID:victorfei,项目名称:interview,代码行数:16,代码来源:reverseInKGrp.py

示例14: test2

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
def test2():
    n1 = ListNode(1)
    n2 = ListNode(2)
    n3 = ListNode(3)
    n4 = ListNode(4)
    n5 = ListNode(5)
    n6 = ListNode(6)

    n1.next = n2
    n2.next = n3
    n3.next = n4
    n4.next = n5
    n5.next = n6
    ListNode.print_ll(n1)
    ListNode.print_ll(rotateLSegment(n1, 1, 4))
开发者ID:victorfei,项目名称:interview,代码行数:17,代码来源:rotateListSegment.py

示例15: test1

# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import next [as 别名]
def test1():
    n1 = ListNode(1)
    n2 = ListNode(2)
    n3 = ListNode(3)
    n4 = ListNode(4)
    n5 = ListNode(5)
    n6 = ListNode(6)

    n1.next = n2
    n2.next = n3
    n3.next = n4
    n4.next = n5
    n5.next = n6
    #ListNode.print_ll(revKGrp(n1, 2))
    ListNode.print_ll(revKGroup_r(n1, 1))
开发者ID:victorfei,项目名称:interview,代码行数:17,代码来源:reverseInKGrp.py


注:本文中的ListNode.ListNode.next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。