Challenge: Return the Nth Node from End

Try to solve the Return the Nth Node from End problem.

We'll cover the following

Statement

Given the head of a linked list, return the nthn^{th} node from the end of the linked list.

Constraints:

  • The number of nodes in the list is kk.

  • 11 \leq kk 103 \leq 10^3

  • 103-10^3\le Node.data 103\leq 10^3

  • 11\len \lekk

Examples

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.