Problem Submissions Solution

Kth from End of Linked List

Difficulty: Medium

Acceptance: %

Points: 30.00

Given the head of a linked list and the number k, Your task is to find the kth node from the end. If k is more than the number of nodes, then the output should be -1.

Topics

Companies

Articles

Examples:

Expected Time Complexity: O(n)

Expected Space Complexity: O(1)

Constraints:
  • 1 <= number of nodes <= 10^6
  • 1 <= node->data , x <= 10^6
  • 1 <= k <= 10^6
Companies:
Amazon Samsung Flipkart Qualcomm
Topics:
Linked List
Locked Content
Access Restricted: Please Login to access the code editor and test cases.