You are given a circular doubly linked list that contains integers as the data in each node. These data on each node is distinct. You have developed a special algorithm that prints the three continuous elements of the list, starting from the first element or head of the list and runs for infinite time. For example, if the list is {1,9,12,7}, then the output of the algorithm will be {1,9,12,9,12,7,12,7,1,...}. The output contains the infinite number of elements because it is a circular list.
You are given only a part of the output that has been returned by the algorithm. Your task is to determine the number of elements available in the original list and print the respective elements.
Note
class Node {
Object data;
Node next;
Node prev;
}
Input format
Output format
Your task is to print the output in the following format:
Constraints
1≤N≤1051≤A[i]≤109
The hidden list is actually [7,12,8,13] with 4 elements hence the output is 4.
Note: You can see that the above list actually matches the output of the program of Alice 7,12,8,12,8,13,8,13,7,13,7,12...