Problem Submissions Solution

Reverse a Linked List in Groups

Difficulty: Medium

Acceptance: %

Points: 30.00

Given a linked list, the task is to reverse the nodes in groups of size k (where k is provided as input). If the total number of nodes is not a multiple of k, the remaining nodes at the end should be treated as a smaller group and reversed as well.

Topics

Companies

Articles

Examples:

Expected Time Complexity: O(n)

Expected Space Complexity: O(1)

Constraints:
  • 1 <= size of linked list <= 10^6
  • 1 <= data of nodes <= 10^6
  • 1 <= k <= size of linked list
Companies:
Amazon Microsoft Visa Walmart Adobe + 1 more
Topics:
Linked List
Locked Content
Access Restricted: Please Login to access the code editor and test cases.