Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6376 |

@mb1973 | 5604 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3413 |

Complete Leaderboard | |

Handle | Score |

@codersgroup18 | 799 |

@sriramgoparaju99 | 737 |

@Manikanta punnam | 629 |

@rdakka | 606 |

@prankursharma31 | 597 |

@praveenbgp6 | 546 |

@sanskar94511 | 531 |

@purohitmn02 | 529 |

@yashkaril4 | 517 |

@abhikarshgupta | 474 |

@rohitgarg2825 | 464 |

Complete Leaderboard |

Given a singly linked list and a number k. Write a function to find the (N/k)^{th} element, where N is the number of elements in the list. We need to consider ceil value in case of decimals.

**Input:**

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**. The second line consists of N spaced integers.The last line consists of an integer **k**.

**Output:**

Print the data value of **(N/k)th** node in the Linked List.

**User Task:**

The task is to complete the function **fractional_node**() which should find the n/kth node in the linked list and return its data value.

**Constraints: **

1 <= T <= 100

1 <= N <= 100

**Example:
Input:**

2

6

1 2 3 4 5 6

2

5

2 7 9 3 5

3

**Output:**

3

7

**Explanation:
Testcase 1**: 6/2

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Find n/k th node in Linked list

...