Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Delete a Node #84

Open
ndrohith09 opened this issue Oct 22, 2022 · 2 comments · Fixed by #113
Open

Delete a Node #84

ndrohith09 opened this issue Oct 22, 2022 · 2 comments · Fixed by #113
Assignees
Labels
easy question Further information is requested

Comments

@ndrohith09
Copy link
Member

Delete the node at a given position in a linked list and return a reference to the head node. The head is at position 0. The list may be empty after you delete the node. In that case, return a null value.

Example

image

Function Description

Complete the deleteNode function in the editor below.

deleteNode has the following parameters:

  • SinglyLinkedListNode pointer llist: a reference to the head node in the list
  • int position: the position of the node to remove

Returns

  • SinglyLinkedListNode pointer: a reference to the head of the modified list

Input Format

The first line of input contains an integer , the number of elements in the linked list.
Each of the next lines contains an integer, the node data values in order.
The last line contains an integer, , the position of the node to delete.

Constraints

image

Sample Input

8
20
6
2
19
7
4
15
9
3

Sample Output

20 6 2 7 4 15 9

Explanation

The original list is 20 -> 6 -> 2 -> 19 -> 7 -> 4 -> 15 -> 9 . After deleting the node at position 3, the list is 20 -> 6 -> 2 -> 7 -> 4 -> 15 ->9.

@ndrohith09 ndrohith09 added question Further information is requested easy labels Oct 22, 2022
@krithi113
Copy link
Contributor

krithi113 commented Oct 22, 2022

I would like to solve it in c++

@jaichiranjeeva
Copy link
Contributor

I would also like to solve this in python & Java

jaichiranjeeva added a commit to jaichiranjeeva/hacktoberfest that referenced this issue Oct 24, 2022
jaichiranjeeva added a commit to jaichiranjeeva/hacktoberfest that referenced this issue Oct 24, 2022
resolves cognizance-amrita#84 Delete_a_node in python & java
thekavikumar added a commit that referenced this issue Oct 25, 2022
@thekavikumar thekavikumar reopened this Oct 25, 2022
Simple-Saviour added a commit to Simple-Saviour/hacktoberfest that referenced this issue Oct 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
easy question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants