BETA

Difficulty Level: Basic

Submissions: 7931 Accuracy:

42.3%

Node at a given index in linked list (Function Problem)
     

Given a singly linked list with n nodes, find node at a given index of linked list. 

Input:
You have to complete the method which takes one argument: the head of the linked list. You should not read any input from stdin/console.
The struct Node has a data part which stores the data and a next pointer which points to the next element of the linked list. 
There are multiple test cases. For each test case, this method will be called individually.

Output:

Your function should return data of N'th node.

Constraints:
1 <=T<= 30
1 <=N<= 100
K <= N
1 <=value<= 1000

Example:
Input:

2
6 5
1 2 3 4 657 76
10 2
8 7 10 8 6 1 20 91 21 2

Output:
657
7

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harshit Sidhwa
Author: atharv


					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.