#Leetcode

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

LeetCode MEDIUM 55 Jump Game Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Jump Game
  • Main tags: Array, Dynamic Programming, Greedy

What the problem is really asking

Each position tells how far the player is allowed to jump from that spot.

The goal is not to find the minimum number of jumps. It is only to decide whether the last index is reachable at all.

Continue ...

LeetCode MEDIUM 128 Longest Consecutive Sequence Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

The input is an unsorted integer array. The task is to find the length of the longest run of values that can be arranged as x, x + 1, x + 2, ....

Continue ...

LeetCode MEDIUM 15 3Sum Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: 3Sum
  • Main tags: Array, Two Pointers, Sorting

What the problem is really asking

The input is an integer array, and the goal is to return every unique triplet whose values add up to 0.

Two details make the problem harder than it looks:

Continue ...

LeetCode MEDIUM 31 Next Permutation Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

The array represents one permutation of the numbers.

The task is to mutate it into the very next permutation in lexicographic order, which means:

  • make the number just a little larger
  • keep that increase as small as possible
  • do everything in place

If the current permutation is already the largest possible one, such as [3, 2, 1], then there is no larger answer. In that case, the correct result is the smallest permutation, which is ascending order.

Continue ...

LeetCode MEDIUM 394 Decode String Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Decode String
  • Main tags: String, Stack, Recursion

What the problem is really asking

The input is an encoded string where patterns like 3[ab] mean “repeat ab three times.” The tricky part is that the repeated part can itself contain more encoded pieces, such as 3[a2[c]].

Continue ...

LeetCode MEDIUM 53 Maximum Subarray Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Maximum Subarray
  • Main tags: Array, Divide and Conquer, Dynamic Programming

What the problem is really asking

The input is an integer array, and the task is to choose one contiguous subarray whose sum is as large as possible.

The important constraint is contiguity. This is not “pick the best numbers anywhere in the array.” Once a starting point is chosen, the subarray must be one uninterrupted block.

Continue ...

LeetCode MEDIUM 56 Merge Intervals Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

The input is a list of inclusive intervals like [start, end]. The goal is to combine every set of overlapping intervals and return the smallest list of non-overlapping intervals that covers the same ranges.

Continue ...

LeetCode MEDIUM 7 Reverse Integer Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

Given a signed 32-bit integer, reverse its decimal digits.

Examples:

  • 123 becomes 321
  • -123 becomes -321
  • 120 becomes 21

The catch is that the answer must still fit inside the signed 32-bit range:

Continue ...

LeetCode HARD 4 Median of Two Sorted Arrays Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

Two arrays are already sorted. If they were merged into one larger sorted array, the task would be to return the middle value.

Continue ...