Find kth element from tail of singly linked list in one pass I have tried the below program to find (Kth element from tail) of a singly linked list. I have tried to utilize the length field which I am incrementing whenever an item is added into the list or vice versa.

public Node&lt;T&gt; findKthFromTail(int kthElem) {
    // length has the size of the list
    int kthPos = length - kthElem;

    if (kthPos &lt; 0) {
        return null;
    }

    Node&lt;T&gt; node = head;
    int start = 0;
    while (node != null) {
        if (start == kthPos) {
            // found the node
            break;
        }

        node = node.getNext();
        start++;
    }

    return node;
}
Trust... it's all about trust.

Trust your length is accurate (if it is not, you have other problems).

Then, your code becomes a simple loop:

// length has the size of the list
int kthPos = length - kthElem;

if (kthPos &lt; 0) {
    return null;
}

Node&lt;T&gt; node = head;
while (kthPos-- &gt; 0) {
    node = node.getNext();
}
return node;