GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesKth Car From the End

Gamified challenge · Fast and slow pointers

Kth Car From the End

A train is a singly linked list of cars (ListNodes with a number val and a link next). You get the head car train (at least one car) and a number n with 1 <= n <= the number of cars.

Write removeNth(train, n) (Python: remove_nth(train, n)) that uncouples the n-th car counted from the back (n = 1 is the last car) and returns the head of the remaining train. If the lead car is removed, the new head is the second car; if the only car is removed, return null. Try doing it in one pass.

For 1 → 2 → 3 → 4 → 5 and n = 2 return 1 → 2 → 3 → 5.

Sign in to play Kth Car From the End

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account