7

PROBLEM OF THE DAY: 06/10/2023 | Reverse alternate nodes in Linked List

 11 months ago
source link: https://www.geeksforgeeks.org/videos/problem-of-the-day-06102023-reverse-alternate-nodes-in-linked-list/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Reverse alternate nodes in Linked List

October 07, 2023 |1.1K Views
PROBLEM OF THE DAY: 06/10/2023 | Reverse alternate nodes in Linked List
Problem of the Day, linked-list, Data Structure and Algorithm
 Save  Share  3 Likes
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Linked List but will also help you build up problem-solving skills.

In this problem, we are given, a linked list, you have to perform the following task:

1-Extract the alternative nodes starting from second node.
2- Reverse the extracted list.
3- Append the extracted list at the end of the original list.

Note: Try to solve the problem without using any extra memory.

Example :

Input:
LinkedList = 10->4->9->1->3->5->9->4
Output: 
10 9 3 9 4 5 1 4

Explanation: 
Alternative nodes in the given linked list are 4,1,5,4. Reversing the alternative nodes from the given list, and then appending them to the end of the list results in a list 10->9->3->9->4->5->1->4.

Give the problem a try before going through the video. All the best!!!

Problem Link: https://practice.geeksforgeeks.org/problems/given-a-linked-list-reverse-alternate-nodes-and-append-at-the-end/1
Solution IDE LInk: https://ide.geeksforgeeks.org/online-cpp-compiler/bd179ac1-195a-4f04-9b7c-26a3d2812abc

Read More

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK