#Leetcode

LeetCode MEDIUM 1004 Max Consecutive Ones III Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

This problem sounds like a bit-flipping question, but the useful reframe is simpler:

find the longest contiguous subarray that contains at most k zeroes.

Continue ...

LeetCode MEDIUM 152 Maximum Product Subarray Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

This problem asks for the contiguous subarray whose product is as large as possible.

That sounds close to Maximum Subarray, but products behave very differently from sums. With sums, a very negative running total is usually bad news. With products, a very negative running product can suddenly become the best thing to keep if the next number is also negative.

Continue ...

LeetCode MEDIUM 221 Maximal Square Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Maximal Square
  • Main tags: Array, Dynamic Programming, Matrix

What the problem is really asking

The input is a grid of "0" and "1" values. The job is to find the area of the largest square made entirely of 1s.

The part that usually traps people is the word “square.” A brute-force approach tends to ask:

Continue ...

LeetCode MEDIUM 994 Rotting Oranges Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Rotting Oranges
  • Main tags: Array, Breadth-First Search, Matrix

Problem gist

The grid has three kinds of cells: empty (0), fresh oranges (1), and rotten oranges (2). Every minute, any fresh orange touching a rotten orange in the four main directions also becomes rotten.

Continue ...

LeetCode HARD 410 Split Array Largest Sum Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: HARD
  • Problem: Split Array Largest Sum
  • Main tags: Array, Binary Search, Dynamic Programming, Greedy, Prefix Sum

What the problem is really asking

The input array must be cut into exactly k non-empty, contiguous pieces. Each cut creates one subarray, and the score of a split is the largest subarray sum that appears anywhere in that split.

Continue ...

LeetCode MEDIUM 540 Single Element in a Sorted Array Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

The array is sorted, and every value appears exactly twice except for one value that appears once.

If the array were not sorted, the quickest idea would be XOR: identical values cancel out, so the final XOR is the answer. That works in O(n) time and O(1) space.

Continue ...

LeetCode MEDIUM 912 Sort an Array Summary

Generated by Codex with GPT-5.4

Difficulty: MEDIUM
Problem: Sort an Array

Problem gist

The task is deliberately simple to state: given an integer array, return the same values in ascending order. The interview signal is not whether someone knows Python’s built-in sort, but whether they can implement a sorting strategy with clear time and space guarantees.

Continue ...

LeetCode HARD 85 Maximal Rectangle Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: HARD
  • Problem: Maximal Rectangle
  • Main tags: Array, Dynamic Programming, Stack, Matrix, Monotonic Stack

What the problem is really asking

The matrix contains only "0" and "1", and the goal is to find the area of the largest axis-aligned rectangle made entirely of "1" cells.

Continue ...

LeetCode MEDIUM 189 Rotate Array Summary

Generated by Codex with GPT-5.4

Quick facts

  • Difficulty: MEDIUM
  • Problem: Rotate Array
  • Main tags: Array, Math, Two Pointers

What the problem is really asking

The problem gives an array nums and an integer k. The task is to rotate the array to the right by k positions, modifying the original list in place.

Continue ...

LeetCode MEDIUM 207 Course Schedule Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Course Schedule
  • Main tags: Depth-First Search, Breadth-First Search, Graph Theory, Topological Sort

What the problem is really asking

There are numCourses courses labeled from 0 to numCourses - 1.

Each prerequisite pair [a, b] means course b must be finished before course a.

Continue ...