#Leetcode

LeetCode MEDIUM 78 Subsets Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Subsets
  • Main tags: Array, Backtracking, Bit Manipulation

What the problem is really asking

Given an array nums of distinct integers, return every possible subset of those numbers.

A subset can contain none of the numbers, some of the numbers, or all of the numbers. The empty subset [] is valid, and the full array is valid too. Because the input numbers are distinct, there is no duplicate-handling problem in the base version.

Continue ...

LeetCode HARD 84 Largest Rectangle in Histogram Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

Each bar in the histogram has width 1, and the goal is to find the largest possible rectangle that can be formed by taking one or more adjacent bars.

Continue ...

LeetCode MEDIUM 146 LRU Cache Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: LRU Cache
  • Main tags: Hash Table, Linked List, Design, Doubly-Linked List

What the problem is really asking

This problem is not mainly about storing key-value pairs. It is about building a data structure that can answer two different questions at the same time:

Continue ...

LeetCode MEDIUM 162 Find Peak Element Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

This problem does not ask for the maximum value in the whole array.

It only asks for any index whose value is greater than its neighbors. That is a much weaker requirement, and that weaker requirement is exactly what makes the binary-search solution possible.

Continue ...

LeetCode MEDIUM 238 Product of Array Except Self Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

For each index, the answer should be the product of every number except the one currently sitting at that index.

If the input is [1, 2, 3, 4], then:

Continue ...

LeetCode MEDIUM 424 Longest Repeating Character Replacement Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

The input is a string and a budget k. One operation lets us replace any single character with any other character. The goal is to find the longest substring that can be turned into a string of all one repeated character using at most k replacements.

Continue ...

LeetCode HARD 1944 Number of Visible People in a Queue Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

Each person is looking to the right. For every position, the task is to count how many people are visible before the view is blocked.

Continue ...

LeetCode HARD 354 Russian Doll Envelopes Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

Each envelope has a width and a height. One envelope can go inside another only if both dimensions are strictly smaller.

So the real question is:

Continue ...

LeetCode MEDIUM 167 Two Sum II - Input Array Is Sorted Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

The input array is already sorted in non-decreasing order, and the goal is to find the two numbers whose sum equals the target.

Continue ...

LeetCode MEDIUM 200 Number of Islands Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Number of Islands
  • Main tags: Array, Depth-First Search, Breadth-First Search, Union-Find, Matrix

What the problem is really asking

The grid is a map of water and land:

  • "1" means land
  • "0" means water

An island is one connected piece of land using only the four cardinal directions: up, down, left, and right.

Continue ...