head, the head node of a linked list containing unique integer values.
G, a subset of the values in the linked list.
G, where two values are connected if they appear consecutively in the linked list.
Nis the length of the linked list given by
1 <= N <= 10000.
[0, N - 1].
1 <= G.length <= 10000.
Gis a subset of all values in the linked list.