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:
AmazonSamsungFlipkartQualcomm
Topics:
Linked List
Please log in to access the Submissions tab, where you can review your progress and explore code submissions from other participants.
Please log in to access the Solution tab and view detailed answers and explanations.
Please log in to access the Discussion tab and join conversations with other participants.
Access Restricted: Please Login to access the code editor and test cases.