Problem: Deletion in Circular Linked List

You are provided with a Circular Linked List of integers and a specific integer, referred to as 'key'.

Your task is to implement a function that locates the specified key in the list and removes it. If the key is not present in the list, then it should remain unchanged.

Input:

The first input line contains the integers present in the circular linked list in order. 
The second input line contains a single integer 'key', the key to be deleted.

Output:

The only output line contains the updated circular linked list post deletion.

Example:

Input:
1 2 3 4 5 -1
3
Output:
1 2 4 5 -1
Explanation:

The circular linked list initially consists of nodes with values 1, 2, 3, 4, 5. The key to be deleted is 3. After deletion, the list is 1, 2, 4, 5.

Constraints:

  • 0 <= N <= 10^5
  • 1 <= key <= 10^5
  • 'N' is the length of the Circular Linked List.
  • All integers in the list are unique.
  • -1 marks the end of the linked list, however, the tail of the linked list would be pointing to the head, making it circular in nature.
  • Time limit: 1 sec
Note:
The Circular Linked List before/after deletion may happen to be empty. In that case, only print -1.
AnswerBot
4mo

Implement a function to delete a specific key from a Circular Linked List of integers.

  • Traverse the Circular Linked List to find the key to be deleted.

  • Update the pointers of the previous and next nodes...read more

Help your peers!
Select
Add answer anonymously...
Wolters Kluwer Software Developer Intern 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