0817. Linked List Components
Last updated
Last updated
https://leetcode.com/problems/linked-list-components
You are given the head
of a linked list containing unique integer values and an integer array nums
that is a subset of the linked list values.
Return the number of connected components in nums
where two values are connected if they appear consecutively in the linked list.
Example 1:
Example 2:
Constraints:
The number of nodes in the linked list is n
.
1 <= n <= 104
0 <= Node.val < n
All the values Node.val
are unique.
1 <= nums.length <= n
0 <= nums[i] < n
All the values of nums
are unique.