Logo
MainBooksThoughtsAbout

Patterns

Elixir solutions

20 LeetCode problem solution

LeetCode 20. Valid Parentheses problem is a classic problem for using a Stack data structure to keep track of opening brackets and a Bracket Matching technique to validate brackets in the correct order. Time and Space complexity is O(n).

Read more

LeetCode 20 Valid Parentheses Elixir solution

LeetCode 20. Valid Parentheses is a classic problem for using a list as a Stack data structure, recursion, and pattern matching to keep track of opening brackets and validate them in the correct order. Time and Space Complexity are both O(n).

Read more

1190 LeetCode problem solution

LeetCode 1190. Reverse Substrings Between Each Pair of Parentheses can be solved in O(n) time using a stack, pair mapping, and direction reversal. First, we use a stack to match every pair of parentheses. Then traverse the string and, when a parenthesis is reached, jump to its pair and reverse the direction. This simulates reversing nested substrings without actually reversing them. Only letters are added to the result. This solution uses O(n) additional space.

Read more

1658 LeetCode problem solution

LeetCode 1658. Minimum Operations to Reduce X to Zero solution using the Sliding Window pattern. We transform the problem into finding the longest subarray with sum totalSum - x, which lets us avoid checking removals from both ends directly. The solution runs in O(n) Time complexity with O(1) extra Space.

Read more

LeetCode 3524 & 3525: From a static to a dynamic solution

LeetCode 3524 and 3525 use the same remainder-based idea with two different approaches. The static version uses Dynamic Programming and Modular Arithmetic technique, while the dynamic version extends it with a Segment Tree pattern for efficient updates and range queries.

Read more
PreviousPage 3 of 13Next
☕Support AlgoBytes on Patreon

© 2026 Algobytes

Privaci Policy