Given a singly linked list and a number K, your are required to complete the function modularNode(), that return the modular node of the linked list.
A modular node is the last node of the linked list whose Index is divisible by the number K, i.e. i%k==0.
Input : list = 1->2->3->4->5->6->7 k = 3 Output : 6 Input : list = 3->7->1->9->8 k = 2 Output : 9
The function takes two arguments as input, the reference pointer to the head of the linked list and an integer K.
There will be T, test cases and for each test the function will be called separately.
For each test case the function must return the modular Node data, if no such node is possible then return "-1".
1 2 3 4 5 6 7
19 28 37 46 55
Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.