<?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: JOY SINHA</title>
    <description>The latest articles on DEV Community by JOY SINHA (@sinhajoy).</description>
    <link>https://dev.to/sinhajoy</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F569725%2Fd25e8178-70d4-491c-96db-f2b7f8c08218.jpeg</url>
      <title>DEV Community: JOY SINHA</title>
      <link>https://dev.to/sinhajoy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sinhajoy"/>
    <language>en</language>
    <item>
      <title>Regular Expression Matching</title>
      <dc:creator>JOY SINHA</dc:creator>
      <pubDate>Thu, 03 Feb 2022 05:37:19 +0000</pubDate>
      <link>https://dev.to/sinhajoy/regular-expression-matching-90f</link>
      <guid>https://dev.to/sinhajoy/regular-expression-matching-90f</guid>
      <description>&lt;p&gt;Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where:&lt;/p&gt;

&lt;p&gt;'.' Matches any single character.​​​​&lt;br&gt;
'*' Matches zero or more of the preceding element.&lt;br&gt;
The matching should cover the entire input string (not partial).&lt;/p&gt;

&lt;p&gt;Example 1:&lt;/p&gt;

&lt;p&gt;Input: s = "aa", p = "a"&lt;br&gt;
Output: false&lt;br&gt;
Explanation: "a" does not match the entire string "aa".&lt;br&gt;
Example 2:&lt;/p&gt;

&lt;p&gt;Input: s = "aa", p = "a*"&lt;br&gt;
Output: true&lt;br&gt;
Explanation: '*' means zero or more of the preceding element, 'a'. Therefore, by repeating 'a' once, it becomes "aa".&lt;br&gt;
Example 3:&lt;/p&gt;

&lt;p&gt;Input: s = "ab", p = ".&lt;em&gt;"&lt;br&gt;
Output: true&lt;br&gt;
Explanation: ".&lt;/em&gt;" means "zero or more (*) of any character (.)".&lt;/p&gt;

&lt;p&gt;Constraints:&lt;/p&gt;

&lt;p&gt;1 &amp;lt;= s.length &amp;lt;= 20&lt;br&gt;
1 &amp;lt;= p.length &amp;lt;= 30&lt;br&gt;
s contains only lowercase English letters.&lt;br&gt;
p contains only lowercase English letters, '.', and '&lt;em&gt;'.&lt;br&gt;
It is guaranteed for each appearance of the character '&lt;/em&gt;', there will be a previous valid character to match.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Code : - *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;def isMatch(self, s: str, p: str) -&amp;gt; bool:&lt;br&gt;
        return self.isMat(s, p, len(s)-1, len(p)-1, False)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def isMat(self, s: str, p: str, si: int, pi: int, isAst):
    if pi &amp;lt; 0:
        return si &amp;lt; 0
    if p[pi] == '*':
        return self.isMat(s, p, si, pi-1, True)

    result = False
    if isAst:
        if si &amp;gt;= 0 and self.compare(s[si], p[pi]):
            result = result or self.isMat(s, p, si-1, pi, True) 
        result = result or self.isMat(s, p, si, pi-1, False)
    elif si &amp;gt;= 0 and self.compare(s[si], p[pi]):
        result = result or self.isMat(s, p, si-1, pi-1, False)

    return result

def compare(self, a, b):
    return a == b or a == '.' or b == '.'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
    <item>
      <title>11. Container With Most Water [Leetcode ] </title>
      <dc:creator>JOY SINHA</dc:creator>
      <pubDate>Wed, 23 Jun 2021 16:39:47 +0000</pubDate>
      <link>https://dev.to/sinhajoy/11-container-with-most-water-leetcode-53j6</link>
      <guid>https://dev.to/sinhajoy/11-container-with-most-water-leetcode-53j6</guid>
      <description>&lt;p&gt;Optimized Python 3 Solution for Container with most water problem.&lt;br&gt;
I am using two pointer shifting technique to solve it so that we can reduce time complexity of the solution.&lt;/p&gt;

&lt;p&gt;CODE:-&lt;/p&gt;

&lt;p&gt;class Solution:&lt;br&gt;
    def maxArea(self, height: List[int]) -&amp;gt; int:&lt;br&gt;
        maxArea = 0&lt;br&gt;
        p1 = 0&lt;br&gt;
        p2 = len(height)-1&lt;br&gt;
        while(p1&amp;lt;=p2):&lt;br&gt;
            maxArea = max(maxArea,min(height[p1],height[p2])*(p2-p1))&lt;br&gt;
            if(height[p1]&amp;lt;height[p2]):&lt;br&gt;
                p1=p1+1&lt;br&gt;
            else:&lt;br&gt;
                p2=p2-1&lt;br&gt;
        return maxArea&lt;/p&gt;

</description>
    </item>
    <item>
      <title>1. Two Sum
[From Leet code]</title>
      <dc:creator>JOY SINHA</dc:creator>
      <pubDate>Wed, 23 Jun 2021 16:37:11 +0000</pubDate>
      <link>https://dev.to/sinhajoy/1-two-sum-from-leet-code-5f00</link>
      <guid>https://dev.to/sinhajoy/1-two-sum-from-leet-code-5f00</guid>
      <description>&lt;p&gt;Brute force:&lt;/p&gt;

&lt;p&gt;for i in range(len(nums)):&lt;br&gt;
    for j in range(i + 1, len(nums)):&lt;br&gt;
        if nums[i] + nums[j] == target:&lt;br&gt;
            return [i, j]&lt;br&gt;
Runtime: 3584 ms, faster than 14.38% of Python online submissions for Two Sum.&lt;br&gt;
Memory Usage: 14.5 MB, less than 14.64% of Python online submissions for Two Sum.&lt;/p&gt;

&lt;p&gt;Two-pass Hash Table:&lt;/p&gt;

&lt;p&gt;nums_hash = {}&lt;br&gt;
for index, num in enumerate(nums):&lt;br&gt;
    nums_hash[num] = index&lt;/p&gt;

&lt;p&gt;for index, num in enumerate(nums):&lt;br&gt;
    comp = target - num&lt;br&gt;
    if comp in nums_hash.keys() and index != nums_hash[comp]:&lt;br&gt;
        return [index, nums_hash[comp]]&lt;br&gt;
Runtime: 1348 ms, faster than 24.52% of Python online submissions for Two Sum.&lt;br&gt;
Memory Usage: 14.2 MB, less than 46.97% of Python online submissions for Two Sum.&lt;/p&gt;

&lt;p&gt;One-pass Hash Table:&lt;/p&gt;

&lt;p&gt;nums_hash = {}&lt;br&gt;
for index, num in enumerate(nums):&lt;br&gt;
    comp = target - num&lt;br&gt;
    if comp in nums_hash.keys() and index != nums_hash[comp]:&lt;br&gt;
        return [index, nums_hash[comp]]&lt;br&gt;
    else:&lt;br&gt;
        nums_hash[num] = index&lt;br&gt;
Runtime: 680 ms, faster than 27.87% of Python online submissions for Two Sum.&lt;br&gt;
Memory Usage: 14.3 MB, less than 46.97% of Python online submissions for Two Sum.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
