Rearrange odd and even places
Rearrange and return a linked list in such a way that all odd position nodes are together and all even positions node are together
You just need to return the head of new linked list, don't print the elements.
Input format :
Line 1 : Linked list elements of length n (separated by space and terminated by -1)
Output format :
Updated list elements (separated by space)
Constraints :
1 <= n <= 10^4
AnswerBot
1y
The task is to rearrange a linked list such that all odd position nodes are together and all even position nodes are together.
Create two separate linked lists, one for odd position nodes and one for e...read more
CodingNinjas
author
2y
Tip 1 : Constant communication
Tip 2 : Give a solution and then optimize it
CodingNinjas
author
2y
Space Complexity: Explanation: Time Complexity: Explanation:
Add answer anonymously...
Top Rupeek Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Rupeek Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app