
Asked in NCR Corporation
Reverse a Doubly Linked List
Given a doubly linked list of positive integers with size 'N', reverse the list and return the head of the modified list.
Explanation:
A doubly linked list allows traversal in both directions, forward and backward.
Input:
The input begins with an integer 'T', representing the number of test cases.
Each test case comprises elements of the doubly linked list, separated by a space and terminated by -1, indicating the end of the list.
Output:
For each test case, output the elements of the reversed list, separated by a space and followed by -1.
Provide the output of each test case in a separate line.
Example:
Input:
2
1 2 3 -1
4 5 6 7 -1
Output:
3 2 1 -1
7 6 5 4 -1
Constraints:
1 <= T <= 100
1 <= N <= 10^4
0 <= data <= 10^3

AnswerBot
1y
The task is to reverse a given doubly linked list and return the head of the modified list.
Create three pointers: prev, current, and next.
Iterate through the linked list and update the next and prev p...read more
Help your peers!
Add answer anonymously...
Top Software Developer Intern Interview Questions Asked at NCR Corporation
Q. Longest Palindromic Substring Problem Statement You are provided with a string S...read more
Q. Count Distinct Ways to Reach the Nth Stairs Consider a scenario where you have b...read more
Q. Can you describe your projects and the tech stack you used in them?
Interview Questions Asked to Software Developer Intern at Other Companies
Top Skill-Based Questions for NCR Corporation Software Developer Intern
C++ Interview Questions and Answers
300 Questions
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Operating Systems Interview Questions and Answers
250 Questions
System Design Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


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
AmbitionBox Awards
Get AmbitionBox app

