InterviewSolution
| 1. |
How Do You Reverse Every Alternate K Nodes Of A Linked List In Java? |
|
Answer» This is another difficult linked list algorithm question which is mostly asked to experienced programmers e.g. programmer having 3 to 6 years of experience. You have been given a singly linked list and you need to write a function to reverse every alternate k nodes (where k is an input to the function) in an efficient way. You also need to calculate the time and space COMPLEXITY of your algorithm. Example: INPUTS: 1->2->3->4->5->6->7->8->9->NULL and k = 3 Output: 3->2->1->4->5->6->9->8->7->NULL. This is another difficult linked list algorithm question which is mostly asked to experienced programmers e.g. programmer having 3 to 6 years of experience. You have been given a singly linked list and you need to write a function to reverse every alternate k nodes (where k is an input to the function) in an efficient way. You also need to calculate the time and space complexity of your algorithm. Example: Inputs: 1->2->3->4->5->6->7->8->9->NULL and k = 3 Output: 3->2->1->4->5->6->9->8->7->NULL. |
|