给定字符串or列表,将其转换成链表
class ListNode:
def __init__(self,x):
self.val=x
self.next=None
def listToListNode(input):
# Generate list from the input
numbers = [int(x) for x in input().split()]
# Now convert that list into linked list
new = ListNode(0)
head = new
for number in numbers:
head.next = ListNode(number)
head = head.next
return new.next