#Leetcode

LeetCode MEDIUM 57 Insert Interval Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

The input intervals are already sorted by start time, and they do not overlap with each other.

That matters because the problem is not asking to rebuild the whole interval set from scratch. It is asking where one new interval fits into an already clean timeline.

Continue ...

LeetCode MEDIUM 73 Set Matrix Zeroes Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

The rule sounds simple:

if any cell contains 0, then every cell in that cell’s row and every cell in that cell’s column must become 0.

Continue ...

LeetCode HARD 32 Longest Valid Parentheses Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

The input is a string made only of ( and ).

The task is not to check whether the whole string is valid. The task is to find the length of the longest contiguous substring that forms a valid parentheses expression.

Continue ...

LeetCode HARD 41 First Missing Positive Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

Given an unsorted integer array, return the smallest positive integer that does not appear in the array.

The tricky part is not the definition of the answer. The tricky part is the constraint: the best solution must run in O(n) time and use only O(1) extra space.

Continue ...

LeetCode MEDIUM 12 Integer to Roman Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

The input is an integer between 1 and 3999, and the output must be its Roman numeral form.

The main challenge is not basic lookup. The hard part is handling the subtractive cases correctly:

Continue ...

LeetCode MEDIUM 130 Surrounded Regions Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Surrounded Regions
  • Main tags: Array, Depth-First Search, Breadth-First Search, Union-Find, Matrix

What the problem is really asking

The board contains X and O. The task is to flip only the O cells that belong to regions fully enclosed by X.

The important phrase is “surrounded region.” A region is safe if it can reach the border through adjacent O cells. A region is captured only if there is no such path.

Continue ...

LeetCode MEDIUM 16 3Sum Closest Summary

Generated by Codex with GPT-5

Quick facts

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

What the problem is really asking

The input is an integer array and a target value. The job is to pick exactly three numbers whose sum is as close to the target as possible.

Continue ...

LeetCode MEDIUM 176 Second Highest Salary Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

There is an Employee table with a salary column. The task is to return the second-highest distinct salary value.

That word “distinct” is the whole trick.

If the largest salary appears many times, it still counts as only one rank. So this is not:

Continue ...

LeetCode MEDIUM 19 Remove Nth Node From End of List Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

The input is a singly linked list and a positive integer n.

The task is to delete the node that is n positions from the end and return the new head.

Continue ...

LeetCode HARD 10 Regular Expression Matching Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

This problem is not asking for a full regex engine.

It asks for one very specific kind of full-string match:

  • . matches exactly one arbitrary character
  • * means “repeat the immediately previous token zero or more times”
  • the whole string must match the whole pattern

That last rule is the detail that makes many first attempts fail. A match is not enough if there are leftover characters in either the text or the pattern.

Continue ...