LeetCode MEDIUM 416 Partition Equal Subset Sum Summary

Generated by Codex with GPT-5

Quick facts

What the problem is really asking

The input is an array of positive integers. The task is to decide whether the array can be split into two subsets whose sums are exactly equal.

Continue ...

LeetCode HARD 3721 Longest Balanced Subarray II Summary

Generated by Codex with GPT-5

Quick facts

Problem gist

The input is an integer array. A subarray is balanced when the number of distinct even values inside it equals the number of distinct odd values inside it. Repeated copies of the same number only count once, so [3, 2, 2, 5, 4] has two distinct odd values, 3 and 5, and two distinct even values, 2 and 4.

Continue ...

LeetCode 703-variant Kth Largest with Dynamic K Summary

Generated by Claude with claude-opus-4-7

Quick facts

Problem gist

Design a collection that supports two operations in any interleaving:

  • insert(num) — add a number to the collection.
  • find_kth_largest(k) — return the k-th largest element currently in the collection.

The twist versus the original LeetCode 703 is that k is a parameter of every query and may change from call to call. The classic min-heap-of-size-k solution relied on k being fixed at construction so it could safely discard everything below the running k-th largest. Once k can grow on a later call, no element is safe to throw away, and the whole strategy has to change.

Continue ...

LeetCode HARD Encode Any Input to JSON String Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: HARD
  • Problem: Custom LeetCode-style prompt: Encode Any Input to JSON String
  • Topics: Serialization, Depth-First Search, Hash Table, Graph, Design

Problem gist

The task is to write an encoder that accepts an input value and returns the same kind of string a normal JSON serializer would return:

Continue ...

LeetCode MEDIUM 371 Sum of Two Integers Summary

Generated by Codex with GPT-5

Quick facts

Problem gist

The task is to return the sum of two signed integers without using the + or - operators. The important constraint is not about math knowledge; it is about understanding how binary addition works under the hood.

Continue ...

LeetCode MEDIUM 402 Remove K Digits Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Remove K Digits
  • Topics: String, Stack, Greedy, Monotonic Stack

Problem gist

The problem gives a non-negative integer as a string and asks for the smallest possible number after removing exactly k digits. The answer must not keep unnecessary leading zeroes, and if every digit is removed or the remaining digits are all zeroes, the answer is "0".

Continue ...

LeetCode MEDIUM Two-Color Necklace Splitting Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Custom LeetCode-style prompt: Two-Color Necklace Splitting
  • Topics: Array, Sliding Window, Prefix Sum, Greedy, Math

Problem gist

This is a special case of the necklace splitting problem: two people, two bead types, and therefore at most two cuts. The input is a necklace represented as an array containing only X and Y. Suppose the full array has:

Continue ...

LeetCode MEDIUM 240 Search a 2D Matrix II Summary

Generated by Codex with GPT-5

Quick facts

Problem gist

The matrix is sorted in two directions at once. Every row is sorted from left to right, and every column is sorted from top to bottom. Given a target value, the task is to decide whether the target appears anywhere in the matrix.

Continue ...

LeetCode MEDIUM 279 Perfect Squares Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Perfect Squares
  • Topics: Math, Dynamic Programming, Breadth-First Search

Problem gist

Given a positive integer n, the task is to return the fewest perfect square numbers whose sum is exactly n. A perfect square is a number such as 1, 4, 9, 16, and so on.

Continue ...

LeetCode MEDIUM 304 Range Sum Query 2D - Immutable Summary

Generated by Codex with GPT-5

Quick facts

Problem gist

The class receives a fixed 2D matrix and must answer many rectangle-sum queries. Each query gives the top-left cell (row1, col1) and the bottom-right cell (row2, col2), and asks for the sum of every matrix value inside that inclusive rectangle.

Continue ...