public LinkedNode nthToLastElement(LinkedNode head, int elementToRemove){
        //Can't remove negative element
        if(elementToRemove<0){
            return head;
        }

        LinkedNode current = head;
        int size = 1;

        while(current.getNext()!=null){
            current=current.getNext();
            size++;
        }
        //Can't remove an element equal to or greater than the size of linked list
        if(elementToRemove>=size){
            return head;
        }

        current = head;
        for(int i=0; i<size-2-elementToRemove; i++){
            current=current.getNext();
        }
        if(head.getNext().getNext()!=null){
            current.nextNode = current.getNext().getNext();
        }
        else{
            current.nextNode = null;
        }
        return head;
    }