PEC-CSS/Open-Source

Nth node from end of linked list

Gauravsharma-20 opened this issue · 11 comments

Given a linked list consisting of L nodes and given a number N. The task is to find the Nth node from the end of the linked list.

Example:
Input:
N = 2
LinkedList: 1->2->3->4->5->6->7->8->9

Output: 8

Explanation: In the first example, there
are 9 nodes in linked list and we need
to find 2nd node from end. 2nd node
from end os 8.

Your Task:
The task is to complete the function getNthFromLast() which takes two arguments: reference to head and N and you need to return Nth from the end or -1 in case node doesn't exist..

Note: Try to solve in single traversal.

Can you assign me this issue?

In which file do I have to complete the code?

You have to create your own file with appropriate name and add it to the good-first-issue folder

can you assign me this problem in cpp?

can you assign me this problem in java?

Sir I have this code ready where do i have to submit it?

I am new to github. Please tell me how should i proceed

You would need to create a Pull request, here's how you can do that: https://github.com/PEC-CSS/Open-Source#how-to-contribute