本文整理汇总了Python中ListNode.ListNode.makeList方法的典型用法代码示例。如果您正苦于以下问题:Python ListNode.makeList方法的具体用法?Python ListNode.makeList怎么用?Python ListNode.makeList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListNode.ListNode
的用法示例。
在下文中一共展示了ListNode.makeList方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_quicksort_list
# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import makeList [as 别名]
def test_quicksort_list(self):
A = ListNode.makeList([5, 4, 3, 2, 1, 6, 10, 7, 8, 9])
quicksort_list(A, None)
A.show()
A = ListNode.makeList([2, 1, 2, 4, 5, 9, 8])
quicksort_list(A, None)
A.show()
A = ListNode.makeList([10])
quicksort_list(A, None)
A.show()
示例2: test_hasCycle
# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import makeList [as 别名]
def test_hasCycle(self):
s = LeetSolution()
self.assertFalse(s.hasCycle(None))
A = ListNode.makeList([1])
self.assertFalse(s.hasCycle(A))
A.next = A
self.assertTrue(s.hasCycle(A))
A = ListNode.makeList([1, 2, 3, 4, 5])
self.assertFalse(s.hasCycle(A))
A = ListNode.makeList([1, 2, 3, 4, 5])
A.tail.next = A.next.next
self.assertTrue(s.hasCycle(A))
示例3: test_removeNthFromEnd
# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import makeList [as 别名]
def test_removeNthFromEnd(self):
s = LeetSolution()
head = ListNode.makeList([1, 2, 3, 4, 5])
s.removeNthFromEnd(head, 2).show()
head = ListNode.makeList([1, 2])
s.removeNthFromEnd(head, 1).show()
head = ListNode.makeList([1])
print(s.removeNthFromEnd(head, 1))
head = ListNode.makeList([1, 2])
s.removeNthFromEnd(head, 2).show()
head = ListNode.makeList([1, 2, 3])
s.removeNthFromEnd(head, 3).show()
示例4: test_detectCycle
# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import makeList [as 别名]
def test_detectCycle(self):
s = LeetSolution()
self.assertEqual(None, s.detectCycle(None))
A = ListNode.makeList([1])
self.assertEqual(None, s.detectCycle(A))
A = ListNode.makeList([1, 2, 3, 4, 5])
self.assertEqual(None, s.detectCycle(A))
A = ListNode.makeList([1])
A.next = A
self.assertEqual(1, s.detectCycle(A).val)
A = ListNode.makeList([1, 2, 3, 4, 5])
A.tail.next = A.next.next
self.assertEqual(3, s.detectCycle(A).val)
示例5: test_mergeKLists2
# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import makeList [as 别名]
def test_mergeKLists2(self):
s = LeetSolution()
values = [sorted([randint(0, 100) for x in range(0, 50)]) for x in range(0, 7)]
new = copy.deepcopy(values)
lists = [ListNode.makeList(value) for value in new]
result = []
for v in values:
result.extend(v)
result.sort()
self.assertEqual(result, s.mergeKLists2(lists).toarray())
示例6: test_insertsort_list
# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import makeList [as 别名]
def test_insertsort_list(self):
A = ListNode.makeList([])
self.assertEqual(None, insertsort_list(A))
A = ListNode.makeList([5, 4, 3, 2, 1, 6, 10, 7, 8, 9])
insertsort_list(A).show()
A = ListNode.makeList([2, 1, 2, 4, 5, 9, 8])
insertsort_list(A).show()
A = ListNode.makeList([1])
insertsort_list(A).show()
A = ListNode.makeList([1, 1])
insertsort_list(A).show()
A = ListNode.makeList(list(range(0, 5000)))
insertsort_list(A).show()
示例7: test_show
# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import makeList [as 别名]
def test_show(self):
array = [1, 2, 3, 4, 5]
head = ListNode.makeList(array)
head.show()
print(head)
示例8: test_mergeTwoLists
# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import makeList [as 别名]
def test_mergeTwoLists(self):
s = LeetSolution()
print(s.mergeTwoLists(None, None))
s.mergeTwoLists(ListNode.makeList([1, 3, 7, 8]), ListNode.makeList([2, 6, 9, 10])).show()
s.mergeTwoLists(ListNode.makeList([1, 3, 7, 8]), None).show()
示例9: test_deleteDuplicates
# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import makeList [as 别名]
def test_deleteDuplicates(self):
s = LeetSolution()
s.deleteDuplicates(ListNode.makeList([1, 1, 2, 3, 3])).show()
s.deleteDuplicates(ListNode.makeList([1, 1, 2])).show()
self.assertIsNone(s.deleteDuplicates(ListNode.makeList(None)))
示例10: test_addTwoNumbers
# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import makeList [as 别名]
def test_addTwoNumbers(self):
s = LeetSolution()
l1 = ListNode.makeList([2, 4, 3])
l2 = ListNode.makeList([5, 6, 4])
print(s.addTwoNumbers(l1, l2))
示例11: test_partition_list
# 需要导入模块: from ListNode import ListNode [as 别名]
# 或者: from ListNode.ListNode import makeList [as 别名]
def test_partition_list(self):
A = ListNode.makeList([5, 4, 3, 2, 1, 6, 10, 7, 8, 9])
par = partition_list(A, None)
print(par.val)
A.show()