<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Farid</title>
    <description>The latest articles on DEV Community by Farid (@faridwants2sleep).</description>
    <link>https://dev.to/faridwants2sleep</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3963014%2Fa1561194-4ba0-4cf0-b704-941309dcbc2e.jpeg</url>
      <title>DEV Community: Farid</title>
      <link>https://dev.to/faridwants2sleep</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/faridwants2sleep"/>
    <language>en</language>
    <item>
      <title>First exposure to Dynamic programming</title>
      <dc:creator>Farid</dc:creator>
      <pubDate>Fri, 19 Jun 2026 11:10:59 +0000</pubDate>
      <link>https://dev.to/faridwants2sleep/first-exposure-to-dynamic-programming-39ok</link>
      <guid>https://dev.to/faridwants2sleep/first-exposure-to-dynamic-programming-39ok</guid>
      <description>&lt;p&gt;I tried solving Leetcode problem #10( Regular Expression Matching) for fun, ended up spending hours on it.&lt;br&gt;
problem Link: &lt;a href="https://leetcode.com/problems/regular-expression-matching/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/regular-expression-matching/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I took a naive greedy string construction approach to check if the string s matched the pattern p.&lt;br&gt;
That worked for simple cases where: p="a*b" s="aaab" output:True&lt;br&gt;
But failed in cases where p ="ab*a*c*a" and s ="aaa", output should be True&lt;/p&gt;

&lt;p&gt;why greedy string construction failed:&lt;br&gt;
the flaw was that a* is not a single choice, it can match "", "a", "aa", "aaa" etc.&lt;br&gt;
To determine if the pattern p matches s, all possibilities of a* must be explored while exploring the rest of the characters. Brute forcing this will result in exponential time complexity.&lt;/p&gt;

&lt;p&gt;So after ELEVEN failed attempts, I finally gave up and searched for the solution. That is where I came across DP top-down approach (recursive memoization).&lt;/p&gt;

&lt;p&gt;The idea of Dynamic programming is to break down complex problem into small sub-problems, saving and reusing the overlapping results.&lt;/p&gt;

&lt;p&gt;After learning the full theory, it took me a couple more tries to come even remotely close to solving it.&lt;br&gt;
Even after taking a look at the solution code, I still made some mistakes when I tried replicating it without looking. &lt;/p&gt;

&lt;p&gt;But either way, this whole process made me really happy, and reminded me of why I loved programming in the first place: Solving problems beautifully.&lt;/p&gt;

&lt;p&gt;P.S. Dynamic programming can be used for bunch of optimization problems including Schedule Optimization, Knapsack, Combinatorial problems, path finding on grids and many more.&lt;/p&gt;

&lt;p&gt;I am hoping to use it for a schedule optimization project that I created a long time ago.&lt;/p&gt;

</description>
      <category>leetcode</category>
      <category>algorithms</category>
    </item>
  </channel>
</rss>
