LeetEye LeetEye
Cheat Sheet

Math & Geometry Cheat Sheet

Quick reference for coding interviews. Bookmark this page!

What is Math & Geometry?

Apply mathematical concepts to algorithmic problems.

Trigger Words

When you see these in a problem, think Math & Geometry:

rotate image math-and-geometry spiral matrix set matrix zeroes happy number plus one pow(x, n) multiply strings detect squares

Template Code

def rotate(matrix: List[List[int]]) -> None:
    n = len(matrix)
    
    # Step 1: Transpose (swap across diagonal)
    for i in range(n):
        for j in range(i + 1, n):
            matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
    
    # Step 2: Reverse each row
    for i in range(n):
        matrix[i].reverse()

Complexity

Typical Time O(n²)
Typical Space O(1)

Common Variations

  • Basic Math & Geometry
  • Math & Geometry with constraints
  • Optimized Math & Geometry

Practice Problems

See all Math & Geometry problems →

Practice Math & Geometry

Learn to recognize patterns instantly with interactive MCQs.

Download LeetEye Free
Practice in LeetEye