Given the head of a singly linked list where each node contains an integer value, insert a new node between every pair of adjacent nodes. The value of each inserted node must be equal to the greatest common divisor of the values of the two adjacent nodes.
Return the head of the linked list after inserting all the new nodes.
Note: The greatest common divisor of two integers is the largest positive integer that evenly divides both numbers.
Constraints:
The number of nodes in the list is in the range
Node.val
Given the head of a singly linked list where each node contains an integer value, insert a new node between every pair of adjacent nodes. The value of each inserted node must be equal to the greatest common divisor of the values of the two adjacent nodes.
Return the head of the linked list after inserting all the new nodes.
Note: The greatest common divisor of two integers is the largest positive integer that evenly divides both numbers.
Constraints:
The number of nodes in the list is in the range
Node.val