Rotations and block rearrangements where the result can be expressed as reordered segments.
- rotate in place
- move a prefix behind a suffix
- reverse words or ranges
Each completed reversal places one required block orientation into the transformation sequence.
O(n) time. Typical auxiliary space: O(1).
JAVA STARTING POINT
A template to adapt, not memorize.
while (left < right) {
int temporary = values[left];
values[left++] = values[right];
values[right--] = temporary;
}Common mistakes
- Not normalizing k
- Using the wrong inclusive boundaries
- Forgetting the empty array
PUBLISHED / 04
Learn in this order.
Available articles always appear before the publishing plan.
Rotate an Array to the Left
Rotate an array by k positions in place with the reversal technique.
Read article →Reverse a Doubly Linked List in Java: Exchange Both Links
Reverse next and prev pointers in place, trace the saved original-next link, preserve node identity and choose safe iteration for long Java lists.
Read article →Reverse a Stack in Java: Understand Every Call and Return
Reverse a stack using recursion only, with insert-at-bottom reasoning, LIFO dry runs, commented Java and edge-case tests.
Read article →Print an Immutable Linked List in Reverse: Java Call-Stack Reasoning
Print backward without changing links or reading hidden fields, using recursive returns, an explicit-stack alternative and an API-faithful dry run.
Read article →PLANNED PRACTICE
What comes after the published lessons.
- Rotate right by kPlanned, not yet published
- Reverse words in a character arrayPlanned, not yet published
