Leetcode – 22. Generate Parentheses

Before we start solving this problem, let’s do some math first. The problem statement clearly states that we have N pairs of parentheses to work with. That means for a string to be considered as part of the solution, it must be of size 2N. Once we have generated a string of size 2N, for it to actually be a …

Mohit AthwaniLeetcode – 22. Generate Parentheses

Leetcode – 10. Regular Expression Matching (Dynamic Programming)

This article is in continuation to my previous article solving the same problem with recursion. The fact that this problem could be solved with recursion made me think about the optimal substructure of this problem. As it turns out, this problem has one and can be solved using dynamic programming. To solve using dynamic programming, we will construct a table …

Mohit AthwaniLeetcode – 10. Regular Expression Matching (Dynamic Programming)

Leetcode – 10. Regular Expression Matching

My initial thought after reading the description of this problem is that let’s just consider, for the moment, that this problem needs to be implemented for • only. For e.g given the text abc does it match a•b? You can come up with examples and you will realize that to implement just the •, the lengths of the two strings …

Mohit AthwaniLeetcode – 10. Regular Expression Matching