LeetCode MEDIUM 930 Binary Subarrays With Sum Summary

Generated by Codex with GPT 5.6 Sol XHigh

Quick facts

Problem gist

Given a binary array nums and a nonnegative integer goal, count the nonempty contiguous subarrays whose elements add up to exactly goal.

Contiguous and exact are the important words. The same element may belong to many valid subarrays, and zeros create several subarrays with the same sum. For example, in [1, 0, 1, 0, 1], there are four different subarrays whose sum is 2.

Continue ...

LeetCode HARD 715 Range Module Summary

Generated by Codex with GPT 5.6 Sol XHigh

Quick facts

  • Difficulty: HARD
  • Problem: Range Module
  • Topics: Design, Segment Tree, Ordered Set

Problem gist

A range module remembers which real-number intervals are currently being tracked. It must support three operations on half-open ranges [left, right):

  • add every point in a range to the tracked set;
  • remove every point in a range from the tracked set;
  • report whether every point in a range is tracked.

The half-open convention matters: adjacent ranges such as [5, 8) and [8, 12) fit together without overlapping, while removing [8, 10) leaves the first range untouched. Operations may overlap in any order, so the data structure must combine additions, preserve removals, and answer queries against the latest state.

Continue ...

LeetCode MEDIUM 622 Design Circular Queue Summary

Generated by Codex with GPT 5.6 Sol XHigh

Quick facts

Problem gist

The task is to build a fixed-capacity first-in, first-out queue. It must support inserting at the rear, deleting from the front, reading both ends, and checking whether it is empty or full. An attempted insertion into a full queue and an attempted deletion from an empty queue must fail cleanly.

Continue ...

LeetCode MEDIUM 678 Valid Parenthesis String Summary

Generated by Codex with GPT 5.6 Sol XHigh

Quick facts

Problem gist

The input contains opening parentheses, closing parentheses, and asterisks. Each * may act as (, act as ), or disappear. The task is to decide whether some choice for every asterisk makes the whole string a valid parenthesis sequence.

Continue ...

LeetCode MEDIUM 570 Managers with at Least 5 Direct Reports Summary

Generated by Codex with GPT 5.6 Sol XHigh

Quick facts

Problem gist

The Employee table stores each employee’s ID, name, department, and manager ID. The task is to return the names of employees who manage at least five other employees directly.

Continue ...

LeetCode MEDIUM 450 Delete Node in a BST Summary

Generated by Codex with GPT 5.6 Sol XHigh

Quick facts

Problem gist

Given a binary search tree and a key, remove the node whose value equals the key and return the tree’s root. If the key is absent, the tree should remain unchanged. Every value is unique, so the binary-search-tree ordering identifies at most one node to delete.

Continue ...

LeetCode MEDIUM 443 String Compression Summary

Generated by Codex with GPT 5.6 Sol XHigh

Quick facts

Problem gist

The input is an array of characters. It must be compressed in place by replacing each maximal run of equal characters with the character followed by the run lengthβ€”except that a run of length one keeps only the character. A count with multiple digits is written one digit at a time. For example, a, a, b, c, c, c becomes the meaningful prefix a, 2, b, c, 3, so the method returns 5.

Continue ...

LeetCode MEDIUM 438 Find All Anagrams in a String Summary

Generated by Codex with GPT 5.6 Sol XHigh

Quick facts

Problem gist

Given a text string s and a shorter pattern string p, the task is to return every starting index in s where a substring is an anagram of p. An anagram may arrange the letters differently, but it must contain exactly the same characters with exactly the same frequencies. Overlapping matches count separately.

Continue ...

LeetCode MEDIUM 373 Find K Pairs with Smallest Sums Summary

Generated by Codex with GPT 5.6 Sol XHigh

Quick facts

Problem gist

Two sorted integer arrays are given. A pair is formed by choosing one value from the first array and one from the second, and its cost is their sum. The task is to return the k pairs with the smallest costs, or every possible pair when fewer than k pairs exist.

Continue ...

LeetCode MEDIUM 337 House Robber III Summary

Generated by Codex with GPT 5.6 Sol XHigh

Quick facts

  • Difficulty: MEDIUM
  • Problem: House Robber III
  • Topics: Dynamic Programming, Tree, Depth-First Search, Binary Tree

Problem gist

Each node in a binary tree represents a house, and its value is the amount of money in that house. Robbing two houses connected by an edge triggers the alarm, so a robbed node rules out its parent and its immediate children. The goal is to choose a valid set of nodes with the largest possible total value.

Continue ...