Lakhankumawat / LearnCPP

Learn Cpp from Beginner to Advanced ✅ Practice 🎯 Code 💻 Repeat 🔁 One step solution for c++ beginners and cp enthusiasts.
https://lakhankumawat.github.io/LearnCPP/
MIT License
598 stars 484 forks source link

Reverse nodes of a Linked List in group of size k #1559

Closed psorat307 closed 2 years ago

psorat307 commented 2 years ago

Description

Given a linked list, write a function to reverse every k nodes (where k is an input to the function).

k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes, in the end, should remain as it is.

Example 1:

Input: 1->2->3->4->5->NULL, K = 2 Output: 2->1->4->3->5->NULL Explaination: As the group size is 2, the first and second node got swapped and then the third and fourth node also got swapped.

Domain

CPP

Type of Contribution

Addition

Code of Conduct

github-actions[bot] commented 2 years ago

Hello @psorat307, thanks for creating your first issue at LearnCPP, hope you followed the guidelines.

psorat307 commented 2 years ago

/assign

github-actions[bot] commented 2 years ago

This issue has been assigned to psorat307! It will become unassigned if it is not closed within 12 days. A maintainer can also add the pinned label to prevent it from being unassigned.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 3 days with no activity. Remove stale label or comment or this will be closed in 2 days.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 5 days with no activity. Please reopen this issue if not resolved.