我好像第一次用gcd這個function
不過要我寫我也不知道怎麼寫
輾轉相除法好難
def insertGreatestCommonDivisors(self, head: Optional[ListNode]) ->
Optional[ListNode]:
headdd = head
while head:
pre = head
head = head.next
if head:
pre.next = ListNode(math.gcd(pre.val, head.val))
pre.next.next = head
return headdd