Pattern
Math & Geometry
These problems turn on a pattern in numbers or in a grid, such as digits, rotations or powers. Work a small case by hand, look for something that never changes, then find a rule that avoids simulating every step. Many need only O(1) extra memory.
1. Happy Numbermath · cycle detection · two pointersEasy2. Plus Onearray · math · carryEasy3. Rotate Imagematrix · in-place · geometryMed.4. Spiral Matrixmatrix · simulation · boundariesMed.5. Set Matrix Zeroesmatrix · in-place · markersMed.6. Pow(x, n)math · binary exponentiation · divide and conquerMed.7. Multiply Stringsstring · math · simulationMed.8. Detect Squaresdesign · hash map · geometryMed.