Find a lesson, question or project

Start typing to search published content and planned structures.

↑ ↓ moveEnter openEsc close
01 / WHAT IT SOLVES

Rotations and block rearrangements where the result can be expressed as reordered segments.

02 / HOW TO RECOGNIZE IT
  • rotate in place
  • move a prefix behind a suffix
  • reverse words or ranges
03 / PROTECT THIS INVARIANT

Each completed reversal places one required block orientation into the transformation sequence.

04 / EXPECTED COST

O(n) time. Typical auxiliary space: O(1).

JAVA STARTING POINT

A template to adapt, not memorize.

Java
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.

PLANNED PRACTICE

What comes after the published lessons.

  1. Rotate right by kPlanned, not yet published
  2. Reverse words in a character arrayPlanned, not yet published