File tree Expand file tree Collapse file tree 1 file changed +0
-17
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +0
-17
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import com .fishercoder .common .classes .ListNode ;
4
4
5
- /**
6
- * 25. Reverse Nodes in k-Group
7
- *
8
- * Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
9
- * k is a positive integer and is less than or equal to the length of the linked list.
10
- * If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.
11
- * You may not alter the values in the nodes, only nodes itself may be changed.
12
- * Only constant memory is allowed.
13
-
14
- For example,
15
- Given this linked list: 1->2->3->4->5
16
-
17
- For k = 2, you should return: 2->1->4->3->5
18
-
19
- For k = 3, you should return: 3->2->1->4->5
20
- */
21
-
22
5
public class _25 {
23
6
24
7
/**We use recursion to go all the way until the end: when the number of nodes are smaller than k;
You can’t perform that action at this time.
0 commit comments