Link: https://leetcode.com/problems/insert-greatest-common-divisors-in-linked-list/description/ ## Code ```python= class Solution: def insertGreatestCommonDivisors(self, head: Optional[ListNode]) -> Optional[ListNode]: currNode = head while currNode.next: nextNode = currNode.next gcdVal = math.gcd(currNode.val, nextNode.val) gcdNode = ListNode(gcdVal) currNode.next = gcdNode gcdNode.next = nextNode currNode = nextNode return head ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up