<?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>Forem: Diganta Chaudhuri</title>
    <description>The latest articles on Forem by Diganta Chaudhuri (@diganta06).</description>
    <link>https://forem.com/diganta06</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%2F561923%2F20c1cad2-7f50-4bfc-bed8-f2730b396d31.jpeg</url>
      <title>Forem: Diganta Chaudhuri</title>
      <link>https://forem.com/diganta06</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/diganta06"/>
    <language>en</language>
    <item>
      <title>CSS Grid - A Better way to style your web page</title>
      <dc:creator>Diganta Chaudhuri</dc:creator>
      <pubDate>Fri, 17 Jun 2022 08:01:48 +0000</pubDate>
      <link>https://forem.com/diganta06/css-grid-a-better-way-to-style-your-web-page-52l5</link>
      <guid>https://forem.com/diganta06/css-grid-a-better-way-to-style-your-web-page-52l5</guid>
      <description>&lt;p&gt;CSS Grid is one of the modern way to write and design webpage. CSS Grid can do such things that Flexbox can't. In this post you will learn some of the basics as well as some advanced CSS Grids tips and tricks to get familiarity about it. So lets get started! 😍😍😍&lt;/p&gt;

&lt;p&gt;Making a div/section/main/ or any other block level element as display grid will not work as it is we have to specify with ROWS and COLUMNS with it. Like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div {
  display: grid;
  grid-tamplate-columuns: 500px 500px 400px;

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;grid-tamplate-columuns: 500px 500px 400px;&lt;/code&gt; This line will brake that div element into 3 separate columns in size 500px 500px and 400px. A better way to write unit in grid is &lt;code&gt;fr&lt;/code&gt;.&lt;br&gt;
if you want 3 columns same size then just write &lt;br&gt;
&lt;code&gt;grid-tamplate-columuns: 1fr 1fr 1fr;&lt;/code&gt; or in short you can use repeat function &lt;code&gt;grid-tamplate-columuns: repeat(3,1fr);&lt;/code&gt;&lt;br&gt;
or if you want make rows you can use grid-tamplate-rows.&lt;br&gt;
If you want to make dynamic rows or column you can use &lt;br&gt;
&lt;code&gt;grid-auto-rows&lt;/code&gt; / &lt;code&gt;grid-auto-columns&lt;/code&gt; followed by the size of that row / column. It's very easy isn't it?😃😃&lt;/p&gt;

&lt;p&gt;Now you have created a grid and make some rows or columns now you have to give some gaps or space between the rows or columns don't worry css grid got you... Just use &lt;code&gt;grid-gap&lt;/code&gt; or short hand &lt;code&gt;gap&lt;/code&gt; property and followed by how much you want to give Thats it....&lt;/p&gt;

&lt;p&gt;Now you may want to place items inside the grid... like you may want to shift a p tag or any you can use align-items / justify-items.&lt;br&gt;
Always remember align-items or justify-items will work on parent element only means which tag you have made grid.&lt;br&gt;
If you want to reposition the child element with tagging that element you have to use align-self / justify-self. &lt;br&gt;
The short hand of this can be &lt;code&gt;place-self&lt;/code&gt; or &lt;code&gt;place-items&lt;/code&gt;;&lt;/p&gt;

&lt;p&gt;The other common term is grid-column-start, grid-column-end, grid-row-start, grid-row-end which is related to positioning of the each of the row or columns.&lt;br&gt;
Determines a grid item’s location within the grid by referring to specific grid lines. grid-column-start/grid-row-start is the line where the item begins, and grid-column-end/grid-row-end is the line where the item ends.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.item {
  grid-column-start: &amp;lt;number&amp;gt; | &amp;lt;name&amp;gt; | span &amp;lt;number&amp;gt; | span &amp;lt;name&amp;gt; | auto;
  grid-column-end: &amp;lt;number&amp;gt; | &amp;lt;name&amp;gt; | span &amp;lt;number&amp;gt; | span &amp;lt;name&amp;gt; | auto;
  grid-row-start: &amp;lt;number&amp;gt; | &amp;lt;name&amp;gt; | span &amp;lt;number&amp;gt; | span &amp;lt;name&amp;gt; | auto;
  grid-row-end: &amp;lt;number&amp;gt; | &amp;lt;name&amp;gt; | span &amp;lt;number&amp;gt; | span &amp;lt;name&amp;gt; | auto;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;syntax can be reduced to grid-column or grid-rows respectively.&lt;/p&gt;

&lt;p&gt;There are many property that css grids provides us but we need some of them above properties are most important among them.&lt;/p&gt;

&lt;p&gt;Thank you🌺🌺&lt;/p&gt;

&lt;p&gt;You can learn more about css grids from MDN Css grids page or CSS tricks . com page they are awasome resourses.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Blind 75 - 1. Two Sum Javascript</title>
      <dc:creator>Diganta Chaudhuri</dc:creator>
      <pubDate>Thu, 16 Jun 2022 13:04:11 +0000</pubDate>
      <link>https://forem.com/diganta06/blind-75-1-two-sum-3gkj</link>
      <guid>https://forem.com/diganta06/blind-75-1-two-sum-3gkj</guid>
      <description>&lt;p&gt;One Of the most popular problem of leetcode is &lt;a href="https://leetcode.com/problems/two-sum/"&gt;2 sum&lt;/a&gt;. This problem can be solved through many ways like 2 pointers, hashing... out of them if Input array is not sorted then the hashing approach is better in terms of Time Complexity. If input array is sorted then the two pointer approach will be better in that case Space Complexity will be reduced down to O(1). &lt;br&gt;
The Hashing approach is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var twoSum = function(nums, target) {
    const mp = new Map();
    for (let i = 0;i &amp;lt; nums.length;i++) {
        let rem = target - nums[i];
        if (mp.has(rem)) {
            return [i, mp.get(rem)];
        }
        mp.set(nums[i], i);
    }
    return [-1,-1];
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The time complexity of this approach is O(N), space complexity is O(N)
&lt;/h2&gt;

&lt;p&gt;If the input array is sorted then we can farther optimise this solution by using 2 pointers&lt;br&gt;
we can place 2 pointers in the both ends&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var twoSum = function(nums, target) {
    let i = 0, j = nums.length-1;
    while (i &amp;lt; j) {
        const sum = nums[i]+nums[j];
        if (sum == target) {
            return [i, j];
        } else if (sum &amp;lt; target) {
          i++;  
        } else {
            j--;
        } 
    }
    return [-1, -1];
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;NOTE: This solution will not work in leetcode because we have to return the indexes so if we sort the input array then it will messed up the indexes.&lt;br&gt;
&lt;a href="https://dev.tourl"&gt;&lt;/a&gt;&lt;br&gt;
The Time Complexity of this approach is O(N) and Space Complexity is O(1).  &lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>algorithms</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
