1. A linked list is said to be circular if it has no node having its next pointer equal to NULL and all the nodes form a circle i.e. the next pointer of last node points to the first node.
2. An empty linked will also be considered as circular.
3. All the integers in the linked list are unique.
4. In the input, the next pointer of a node with i’th integer is linked to the node with data (i+1)’th integer (If (i+1)’th node exists). If there is no such (i+1)’th integer then the next pointer of such node is set to NULL.
The first line of input contains an integer T, denoting the number of test cases.
The first line of each test case consists of an integer N, denoting the number of links in the linked list.
The second line of each test case consists of N space-separated integers denoting the data of the linked list and linking between nodes of the linked list as described in the notes above.
For more clarity please refer to the sample input.
For each test case, print ‘True’ or ‘False’ depending on whether the linked list is circular or not, in a separate line.
You don't have to print anything, it has already been taken care of. Just Implement the given function.
1 <= T <= 10 ^ 2
1 <= D <= 10 ^ 6, here D is data stored in the node.
0 <= N <= 10 ^ 4
Time Limit: 1 sec
Eg. In the linked list given below:
Here, the head is the pointer to the node with data = 1, now initialise slow and fast with head.
Deletion In Doubly Linked List
Deletion In Doubly Linked List
Insertion In Doubly Linked List
Insertion In Doubly Linked List
LRU Cache
Delete Nodes On Regular Intervals
Add One To Linked List