Given a linked list A of length N and an integer B.
You need to find the value of the Bth node from the middle towards the beginning of the Linked List A.
If no such element exists, then return -1.
NOTE:
Problem Constraints
1 <= N <= 10
5
1<= Value in Each Link List Node <= 10
3
1 <= B <= 10
5
Input Format
First argument is the head pointer of the linkedlist A.
Second argument is an integer B.
Output Format
Return an integer denoting the value of the Bth from the middle towards the head of the linked list A. If no such element exists, then return -1.
Example Input
Input 1:
A = 3 -> 4 -> 7 -> 5 -> 6 -> 1 6 -> 15 -> 61 -> 16
B = 3
Input 2:
A = 1 -> 14 -> 6 -> 16 -> 4 -> 10
B = 2