LeetCode 155: Min Stack, Keeping the Minimum in Sync With Stack State

Problem Requirement Design a stack named MinStack that supports these operations: MinStack(): initialize the stack. push(value): push value onto the stack. pop(): remove the top element. top(): return the top element. getMin(): return the minimum element in the stack. Every operation must run in O(1) time. pop, top, and getMin are called only when the stack is non-empty, so no additional empty-stack return value is needed. Example Operations: ["MinStack", "push", "push", "push", "getMin", "pop", "top", "getMin"] Arguments: [[], [-2], [0], [-3], [], [], [], []] Output: [null, null, null, null, -3, null, 0, -2] The sequence corresponds to: ...

August 21, 2026 · 7 min · map[name:Jeanphilo]

LeetCode 20: Valid Parentheses, Why Equal Counts Are Not Enough

Problem Requirement You are given a string s containing only these six characters: ( ) { } [ ] Determine whether the string is valid. A valid string must satisfy all three conditions: Every opening bracket is closed by the same type of closing bracket. Opening brackets are closed in the correct order. Every closing bracket has a corresponding opening bracket of the same type. Return True when all conditions hold; otherwise, return False. ...

August 21, 2026 · 7 min · map[name:Jeanphilo]

LeetCode 394: Decode String by Saving and Restoring Nested Context

Problem Requirement Given an encoded string s, return its decoded string. The encoding rule is: k[encoded_string] The encoded_string inside the brackets is repeated exactly k times, where k is a positive integer. Encodings may be nested or adjacent to ordinary lowercase letters. The problem guarantees that: The input is always valid, with matching brackets and no extra spaces. Original text contains no digits; digits only represent repeat counts. Inputs such as 3a or 2[4] do not occur. The decoded string length does not exceed 10^5. Examples Input Output "3[a]2[bc]" "aaabcbc" "3[a2[c]]" "accaccacc" "2[abc]3[cd]ef" "abcabccdcdcdef" Constraints 1 <= s.length <= 30 s contains only lowercase English letters, digits, and [] Every repeat count is in [1, 300] LeetCode provides this method signature: ...

August 21, 2026 · 10 min · map[name:Jeanphilo]

LeetCode 84: Which Bar Limits a Contiguous Rectangle?

Problem Requirement You are given a non-negative integer array heights. Each heights[i] is the height of a bar with width 1, and all bars are adjacent. Return the area of the largest rectangle that can be formed in the histogram. A legal rectangle covers a contiguous interval of bars. Its width is the number of bars in that interval, and its height cannot exceed the shortest bar in the interval. ...

July 20, 2026 · 10 min · map[name:Jeanphilo]

LeetCode 739: Daily Temperatures and the First Warmer Day to the Right

Problem Requirement You are given an integer array temperatures, where temperatures[i] is the temperature on day i. Return an array answer where: answer[i] = the number of days after day i until a warmer temperature If no later day is warmer, answer[i] = 0. “Warmer” means strictly greater. An equal temperature does not resolve a waiting day. LeetCode provides this method contract: dailyTemperatures(temperatures: List[int]) -> List[int] Example Input: temperatures = [73,74,75,71,69,72,76,73] Output: [1,1,4,2,1,1,0,0] Constraints 1 <= temperatures.length <= 10^5 30 <= temperatures[i] <= 100 Step 1: The Answer Is a Waiting Time, Not a Temperature Start with a smaller input: ...

July 15, 2026 · 6 min · map[name:Jeanphilo]

Hot100: Kth Smallest Element in a BST (Inorder Counting / Early Stop ACERS Guide)

Subtitle / Summary LeetCode 230 is not really about tree traversal mechanics alone. It is about turning BST order into a useful query. Once you see that the k-th smallest value is simply the k-th node visited in inorder traversal, the problem becomes a very stable counting task. Reading time: 11-14 min Tags: Hot100, binary tree, BST, inorder traversal, stack SEO keywords: Kth Smallest Element in a BST, BST, inorder traversal, stack, LeetCode 230 Meta description: Learn LeetCode 230 from BST inorder ordering, explicit-stack counting, and early-stop traversal, with runnable multi-language implementations. A — Algorithm Problem Restatement Given the root root of a binary search tree and an integer k, return the k-th smallest value in the tree. ...

April 20, 2026 · 12 min · map[name:Jeanphilo]

Hot100: Binary Tree Inorder Traversal (Recursion / Stack ACERS Guide)

Subtitle / Summary Binary tree traversal is the starting point of most tree templates, and inorder traversal is one of the cleanest problems for understanding both recursive thinking and explicit stack simulation. This ACERS guide uses LeetCode 94 to explain the left-root-right order, the iterative stack template, and why the pattern matters in real engineering work. Reading time: 10-12 min Tags: Hot100, binary tree, DFS, stack, inorder traversal SEO keywords: Hot100, Binary Tree Inorder Traversal, inorder traversal, explicit stack, LeetCode 94 Meta description: A systematic guide to LeetCode 94 from recursion to explicit stacks, with engineering scenarios and runnable multi-language implementations. Target Readers Hot100 learners who want to lock in a stable tree-traversal template Developers moving from arrays and linked lists to trees, and still mixing up preorder, inorder, and postorder Engineers who want to reuse the left-root-right idea in BSTs, expression trees, or syntax trees Background / Motivation Inorder traversal is not hard by itself, but its training value is high: ...

March 6, 2026 · 11 min · map[name:Jeanphilo]