You are given the head of a singly linked list containing nums containing a subset of the values present in the linked list.
A connected component is defined as a maximal sequence of linked list nodes appearing consecutively such that every node in the sequence has its value present in nums.
Return the total number of connected components formed by the elements of nums.
Constraints:
The number of nodes in the linked list is
Node.val
All the values of Node.val are unique.
nums.length
nums[i]
All the values of nums are unique.
You are given the head of a singly linked list containing nums containing a subset of the values present in the linked list.
A connected component is defined as a maximal sequence of linked list nodes appearing consecutively such that every node in the sequence has its value present in nums.
Return the total number of connected components formed by the elements of nums.
Constraints:
The number of nodes in the linked list is
Node.val
All the values of Node.val are unique.
nums.length
nums[i]
All the values of nums are unique.