Skip to content

Conversation

Mishra-Sagar
Copy link

On line no 183, I have changed this --> k < position -1 to this --> k < position
because if there are 5 elements in the list and you try to delete the 6th one, k < position -1, because of this condition last element was getting removed even if the position does not exist.
I have added one more case in the end

On line no 183, I have changed this --> k < position -1 to this --> k < position
because if there are 5 elements in the list and you try to delete the 6th one, k < position -1, because of this condition last element was getting removed even if the position does not exist.
I have added one more case in the end
@@ -180,7 +180,7 @@ void delete(struct DLLNode **head, int position) {
temp = temp->next;
k++;
}
if(k < position-1){
if(k < position){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @Mishra-Sagar ,
if( k != position) is also valid . What do you say?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants