• + 0 comments
    public static SinglyLinkedListNode deleteNode(SinglyLinkedListNode head, int position) {
        SinglyLinkedListNode temp=head;
        if (head==null||head.next==null) {
            return head;
        }
        else if(position==0){
            head=head.next;
            return head;
        }
            
        for (int i = 0; i < position-1; i++) {
            temp=temp.next;
        }
        temp.next=(temp.next).next;
        return head;
        }