K reverse linked list


Problem Setter: mihai.gheorghe Problem Tester: yashpal1995

Given a singly linked list and an integer K, reverses the nodes of the

list K at a time and returns modified linked list.

NOTE : The length of the list is divisible by K

Example :

Given linked list 1 -> 2 -> 3 -> 4 -> 5 -> 6 and K=2,

You should return 2 -> 1 -> 4 -> 3 -> 6 -> 5

Try to solve the problem using constant extra space.

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving K reverse linked list on Interview Code Editor
Sign Up
to access hints and editorial solutions for K reverse linked list
Asked In:

Discussion


Loading...
Click here to start solving coding interview questions