Logo
MainBooksThoughtsAbout

Patterns

Elixir solutions

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

LeetCode 3870 & 3871: from a simple to a general solution

LeetCode 3870 and 3871 problems look almost the same, but the larger constraints change the solution. This is a good example of why you should always ask about the problem constraints.

Read more

LeetCode 940 Dynamic Programming Solution After LeetCode 115

LeetCode 940 solution using Dynamic Programming with Last Occurrence and Deduplication to count distinct subsequences efficiently in O(n) time and O(1) space.

Read more

LeetCode 115: two solutions - Space optimization using a 1D array

See how a simple 1D array optimization reduces space complexity from O(n * m) to O(m) while keeping O(n * m) time complexity.

Read more

LeetCode 3903: two solutions - O(n²) vs O(n) Time complexity

We're used to evaluating an algorithm's Time complexity, but we often overlook its Space complexity. However, often the best solution for Time complexity is a brute-force solution for Space complexity and vice versa.

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

© 2026 Algobytes

Privaci Policy