LeetCode MEDIUM 48 Rotate Image Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Rotate Image
  • Main tags: Array, Math, Matrix

What the problem is really asking

The input is an n x n matrix, and the task is to rotate it 90 degrees clockwise.

The important constraint is that the rotation must happen in place. That means the matrix itself must be rearranged without allocating another full n x n matrix for the final answer.

Continue ...

LeetCode MEDIUM 72 Edit Distance Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Edit Distance
  • Main tags: String, Dynamic Programming

What the problem is really asking

Two strings are given, word1 and word2.

The goal is to transform word1 into word2 using as few operations as possible. The allowed operations are:

  • insert one character
  • delete one character
  • replace one character

This is not a greedy string-matching problem. A locally good edit can make the rest of the string worse, so the real challenge is deciding which prefixes of the two words should be matched together.

Continue ...

LeetCode MEDIUM 75 Sort Colors Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Sort Colors
  • Main tags: Array, Two Pointers, Sorting

What the problem is really asking

The input array contains only 0, 1, and 2. Those values represent three categories, and the goal is to reorder the array in place so all 0s come first, then all 1s, then all 2s.

Continue ...

LeetCode HARD 51 N-Queens Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: HARD
  • Problem: N-Queens
  • Main tags: Array, Backtracking

What the problem is really asking

The board details can make this problem look more complicated than it is.

At a higher level, the task is:

  • place exactly one queen in each row
  • never reuse a column
  • never place two queens on the same diagonal
  • return every full placement that satisfies those rules

That “one queen per row” reframing is the key simplification.

Continue ...

LeetCode MEDIUM 198 House Robber Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: House Robber
  • Main tags: Array, Dynamic Programming

What the problem is really asking

Each house has some amount of money. The thief wants the largest total possible, but robbing two neighboring houses triggers the alarm.

So the real question is:

At every house, is it better to:

Continue ...

LeetCode MEDIUM 22 Generate Parentheses Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

Given n pairs of parentheses, generate every string that is:

  • exactly 2n characters long
  • made only of ( and )
  • balanced at every point

The last condition is the important one.

Continue ...

LeetCode MEDIUM 33 Search in Rotated Sorted Array Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

The array started out sorted in ascending order, then got rotated at some pivot.

That means a sequence like [0, 1, 2, 4, 5, 6, 7] might become [4, 5, 6, 7, 0, 1, 2].

Continue ...

LeetCode MEDIUM 34 Find First and Last Position of Element in Sorted Array Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

The input array is sorted, and the target value may appear many times in one contiguous block.

The task is not just to decide whether the target exists. It is to return the exact starting and ending indices of that block.

Continue ...

LeetCode MEDIUM 49 Group Anagrams Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Group Anagrams
  • Main tags: Array, Hash Table, String, Sorting

What the problem is really asking

Two strings belong in the same group if they use the exact same letters with the exact same counts, just in a different order.

So the problem is not really about comparing every string against every other string. It is about finding a stable “signature” for each word, so all words with the same signature land in the same bucket.

Continue ...

LeetCode MEDIUM 54 Spiral Matrix Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Spiral Matrix
  • Main tags: Array, Matrix, Simulation

What the problem is really asking

The input is a 2D matrix. The task is to return every value exactly once in spiral order:

  • go left to right across the top
  • then top to bottom down the right side
  • then right to left across the bottom
  • then bottom to top up the left side
  • keep repeating until there is nothing left

This is a traversal problem. Nothing in the matrix needs to be modified. The only challenge is knowing when to turn and when a side has already been fully consumed.

Continue ...