• + 0 comments

    Java 8 Solution:

    public static SinglyLinkedListNode deleteNode(SinglyLinkedListNode llist, int position) {
            if (position == 0) {
                llist = llist.next;
                return llist;
            }
            SinglyLinkedListNode current = llist;
            llist = current;
            
            int index = 0;
            while (index < position - 1) {
                current = current.next;
                index++;
            }
            current.next = current.next.next;
            return llist;
        }