LeetCode MEDIUM 1339 Maximum Product of Splitted Binary Tree Summary

Generated by Codex with GPT 5.6 Sol XHigh

Quick facts

Problem gist

The input is a binary tree whose nodes contain positive integers. Exactly one edge must be removed, splitting the original tree into two smaller trees. Each smaller tree has a sum, and the goal is to choose the cut that maximizes the product of those two sums. The product must be maximized as an ordinary integer; only the final answer is reduced modulo $10^9 + 7$.

Continue ...

LeetCode MEDIUM 811 Subdomain Visit Count Summary

Generated by Codex with GPT 5.6 Sol XHigh

Quick facts

Problem gist

Each input string pairs a visit count with a domain, such as "9001 discuss.leetcode.com". A visit to that domain also counts as a visit to every parent domain: leetcode.com and com in this example. The task is to total the visits for every full domain and parent subdomain that appears implicitly or explicitly in the input. The output order does not matter.

Continue ...

LeetCode MEDIUM 735 Asteroid Collision Summary

Generated by Codex with GPT-5

Quick facts

Problem gist

The input describes asteroids arranged from left to right. A positive number moves right, a negative number moves left, and the absolute value is the asteroid’s size. When two asteroids meet, the smaller one disappears; if their sizes are equal, both disappear. The goal is to return the asteroids that remain, in their original left-to-right order.

Continue ...

LeetCode MEDIUM 621 Task Scheduler Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Task Scheduler
  • Topics: Array, Hash Table, Greedy, Sorting, Heap (Priority Queue), Counting

Problem gist

Given a list of CPU tasks and a cooldown n, the scheduler must run every task while making sure two equal task types are separated by at least n time units. In each time unit, the CPU can either execute one task or sit idle. The goal is not to print the schedule; it is to return the smallest possible number of time units needed.

Continue ...

LeetCode MEDIUM 721 Accounts Merge Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Accounts Merge
  • Topics: Array, Hash Table, String, Depth-First Search, Breadth-First Search, Union-Find, Sorting

Problem gist

Each account is a list where the first value is a person’s name and the remaining values are email addresses. Two accounts belong to the same real person if they share at least one email address. The task is to merge every connected set of accounts and return one account per person, with the person’s name followed by that person’s emails in sorted order.

Continue ...

LeetCode MEDIUM 567 Permutation in String Summary

Generated by Codex with GPT-5

Quick facts

Problem gist

Given two strings s1 and s2, the task is to decide whether s2 contains any contiguous substring that is a permutation of s1.

That means order inside the matching substring does not matter, but the character counts must match exactly. If s1 = "ab", then "ab" and "ba" are both valid windows. If s2 contains either one as a length-2 substring, the answer is True.

Continue ...

LeetCode MEDIUM 547 Number of Provinces Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Number of Provinces
  • Topics: Depth-First Search, Breadth-First Search, Union-Find, Graph Theory

Problem gist

There are n cities, and isConnected[i][j] tells whether city i is directly connected to city j. A province is a full connected component: if city 0 is connected to city 1, and city 1 is connected to city 2, then all three cities belong to the same province even if 0 and 2 are not directly connected.

Continue ...

LeetCode MEDIUM 525 Contiguous Array Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: MEDIUM
  • Problem: Contiguous Array
  • Topics: Array, Hash Table, Prefix Sum

Problem gist

Given a binary array, find the longest contiguous subarray that contains the same number of 0s and 1s.

The key constraint is that the answer must be a single continuous slice, not a subset. A brute-force check of every slice works logically, but it takes too long because there are O(n^2) possible slices. The useful observation is that “same number of zeros and ones” can be turned into a prefix-sum equality problem.

Continue ...

LeetCode HARD 460 LFU Cache Summary

Generated by Codex with GPT-5

Quick facts

  • Difficulty: HARD
  • Problem: LFU Cache
  • Topics: Hash Table, Linked List, Design, Doubly-Linked List

Problem gist

Design a cache with a fixed capacity that supports two operations:

  • get(key): return the value for key, or -1 if the key is absent.
  • put(key, value): insert or update a key-value pair.

When the cache is full, it must evict the least frequently used key. If multiple keys have the same lowest frequency, it evicts the least recently used key among them.

Continue ...

LeetCode HARD 233 Number of Digit One Summary

Generated by Codex with GPT-5

Quick facts

Problem gist

Given a non-negative integer n, the task is to count how many times the digit 1 appears when writing every number from 0 through n.

For example, from 0 to 13, the digit 1 appears in 1, 10, 11, 12, and 13. Counting each occurrence gives 6: one in 1, one in 10, two in 11, one in 12, and one in 13.

Continue ...