Delete a Node from Linked List Problem Statement

Given a linked list of integers, your task is to implement a function that deletes a node at a specified position, 'POS'.

If the specified position is greater than or equal to the length of the linked list, return the linked list unchanged.

Input:

The first line of input contains an integer 'T', which indicates the number of test cases or queries. Each test case consists of two lines. The first line contains the elements of the linked list separated by spaces. The second line contains an integer 'POS', which denotes the position to delete the node from.

Output:

For each test case, output the resulting linked list with integers separated by spaces. Each output should be on a separate line.

Example:

Input:
3
3 4 5 6 -1
2
1 2 3 4 5 -1
4
10 20 30 40 -1
0
Output:
3 4 6
1 2 3 4
20 30 40

Constraints:

  • 1 <= T <= 10^2
  • 0 <= N <= 10^5
  • POS >= 0

Note: Assume that the indexing for the linked list starts from 0, and -1 indicates the end of the singly linked list and is not a list element.

AnswerBot
4mo

Implement a function to delete a node at a specified position in a linked list.

  • Traverse the linked list to find the node at the specified position.

  • Update the pointers to skip the node to be deleted.

  • Ha...read more

Help your peers!
Select
Add answer anonymously...

Paytm Software Developer interview questions & answers

A Software Developer was asked 4mo agoQ. Given a sorted array of integers nums and an integer target, write a function to...read more
A Software Developer was asked 6mo agoQ. What is multithreading?
A Software Developer was asked 7mo agoQ. Given a 2D grid map of '1's (land) and '0's (water), count the number of islands...read more

Popular interview questions of Software Developer

A Software Developer was asked 4mo agoQ1. Given a sorted array of integers nums and an integer target, write a function to...read more
A Software Developer was asked 6mo agoQ2. What is multithreading?
A Software Developer was asked 7mo agoQ3. Given a 2D grid map of '1's (land) and '0's (water), count the number of islands...read more
Paytm Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits