<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sravya Divakarla on Medium]]></title>
        <description><![CDATA[Stories by Sravya Divakarla on Medium]]></description>
        <link>https://medium.com/@sravyadivakarla?source=rss-6dd97d5e3702------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ApAlDX9tv5lO8g53.</url>
            <title>Stories by Sravya Divakarla on Medium</title>
            <link>https://medium.com/@sravyadivakarla?source=rss-6dd97d5e3702------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:31:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sravyadivakarla/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[30. Substring with Concatenation of All Words]]></title>
            <link>https://sravyadivakarla.medium.com/30-substring-with-concatenation-of-all-words-8ad8fc24b746?source=rss-6dd97d5e3702------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ad8fc24b746</guid>
            <category><![CDATA[coding-interviews]]></category>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Sravya Divakarla]]></dc:creator>
            <pubDate>Wed, 18 Oct 2023 02:34:45 GMT</pubDate>
            <atom:updated>2023-10-18T02:34:45.432Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a sliding window with fixed width problem. Its just like this question but with layers (link an onion) <a href="https://l.facebook.com/l.php?u=https%3A%2F%2Fsravyadivakarla.medium.com%2F187-repeated-dna-sequences-23557d59f143%3Ffbclid%3DIwAR3_h8gNJEwdzd83us-W3H0rWs_dAcYBSZ20qXsVwmzY07eZGxFHBXJfm8A&amp;h=AT130Tc_wh6YlWwG_slcptkdMD2coa15bzvTdsdlNyrOIY5bK05xljPSILW6KEwi3LF1YmZtxRh8WFBLmJ9OQGYwmCG4kGuN-d6BRVSGMPHfEoA_4uWELPEYSlG5T0A2zGaBEkKUESLQ3AXKxzIWTOoHSlM">Check this link to learn about the base concept</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/0*gW248_1-W1cikE_5" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p7JwRN-mNOWqabqwEkEeow.png" /></figure><ol><li>The length of each sliding window will be the summation length of each word : words[0].length * words.length</li><li>Then in each window you need to check if all words are present (in whatever permutation order). To check that we create a map to keep track of the words and frequencies.</li><li>So in chunks of the word length, you match the word and reduce the freq/delete from the map</li><li>The sub-string window is only valid if all words were covered (the map is empty)</li><li>If sub-string is valid store its beginning index and set the next window to the end index (so we save time by skipping the contents of the window)</li></ol><pre>var findSubstring = function(s, words) {<br>    // must contain all words <br>    // concatLength = words[0].length * words.length<br>    // s.length &gt; words.length<br><br>    // to search for if the seq is a valid concat <br>    // you need to have another sliding window of words[0].length and make sure each word is hit<br><br>    var res = []<br><br>    var subStrLength = words[0].length * words.length<br>    for(var i = subStrLength; i &lt;= s.length; i++){<br>        var swBeg = i-subStrLength, swEnd = i // start and end of sliding window<br>        <br>        var wordLength = words[0].length<br><br>        // word map to to make sure each word exists in the sliding window<br>        var wordMap = new Map()<br>        words.forEach(word=&gt;{<br>            var wordFreq = wordMap.get(word)<br>            wordFreq ? wordMap.set(word,wordFreq+1) : wordMap.set(word,1)<br>        })<br><br>        // each word length window must watch one word in wordlist or the window is not valid<br>        for(var j = swBeg; j &lt; swEnd; j+=wordLength){<br>            var word = s.slice(j, j+wordLength)<br>            var wordFreq = wordMap.get(word)<br>            wordFreq &gt; 1 ? wordMap.set(word,wordFreq-1) : wordMap.delete(word)<br>            if(!wordFreq) break;<br>        }<br><br>        if(wordMap.size == 0){<br>            res.push(swBeg)<br>            i = swBeg + subStrLength // skip checking the rest of the window <br>        }<br>        <br>    }<br>    return res <br>};</pre><p>not really that hard when you identify the category of the problem huh?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ad8fc24b746" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[187. Repeated DNA Sequences]]></title>
            <link>https://sravyadivakarla.medium.com/187-repeated-dna-sequences-23557d59f143?source=rss-6dd97d5e3702------2</link>
            <guid isPermaLink="false">https://medium.com/p/23557d59f143</guid>
            <category><![CDATA[coding-interviews]]></category>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[interview-questions]]></category>
            <dc:creator><![CDATA[Sravya Divakarla]]></dc:creator>
            <pubDate>Wed, 18 Oct 2023 01:15:41 GMT</pubDate>
            <atom:updated>2023-10-18T01:15:41.538Z</atom:updated>
            <content:encoded><![CDATA[<p>I am practicing sliding window problems. A sliding window with a fixed length is when:</p><p>On each iteration you subtract the previous element from the window and add the next element to the window</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*8dCZezgTu6hRpFy8.png" /></figure><p>In this problem:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ZNHsDyiRDoWM4IdiKadUQ.png" /></figure><p>You want to</p><ol><li>Identify each sequence of 10 through a sliding window</li><li>See if that sequence was already seen in a previous window</li><li>Store duplicate sequences in the resulting array</li></ol><p>I use sets instead of maps as we only care about if the unique sequences is seen (we don’t need a key value pair as there is not info needed for value)</p><p>We also use a set for the resulting array of repeated sequences as we want UNIQUE repeated sequences. If the sequences appears 3 times we don’t want 2 of the same in the returned array. Set allows you to store unique elements only</p><pre>var findRepeatedDnaSequences = function(s) {<br>    var seqSet = new Set()<br>    var res = new Set()<br>    for(var i = 10 ; i &lt; s.length; i++){<br>        var seq = s.slice(i-10,i)  // 1. Identify each sequence of 10 through a sliding window<br>        if(seqSet.has(seq)){ // 2. See if that sequence was already seen in a previous window<br>            res.add(seq) // 3. Store duplicate sequences in the resulting array<br>        }else{<br>            seqSet.add(seq)<br>        }<br>    }<br>    return [...res]<br>};</pre><p>Hope that makes sense!</p><p>Here are more types of window problems you can solve next:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/0*8EVg1GDAnpzp_bOH.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23557d59f143" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[739. Daily Temperatures]]></title>
            <link>https://sravyadivakarla.medium.com/739-daily-temperatures-40f78df3a291?source=rss-6dd97d5e3702------2</link>
            <guid isPermaLink="false">https://medium.com/p/40f78df3a291</guid>
            <category><![CDATA[interview-preparation]]></category>
            <category><![CDATA[leetcode-solution]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[leetcode]]></category>
            <dc:creator><![CDATA[Sravya Divakarla]]></dc:creator>
            <pubDate>Tue, 17 Oct 2023 06:51:24 GMT</pubDate>
            <atom:updated>2023-10-17T06:51:24.544Z</atom:updated>
            <content:encoded><![CDATA[<p>This questions made me question life in general.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uJTR_BAVCIyEqrq3NY3xOQ.png" /></figure><p>So I started out this questions with absolutely no clue on how to start. So I started looking at the pattern of how I would solve it using iteration in my own head.</p><p>I would start from the beginning and remember the each number until I see the next larger number, then calculate the distance. So I needed some sort of storage that would remember a array of numbers until conditions met.</p><p>Initial logic</p><ol><li>keep adding to the stack until I saw a larger number.</li><li>when topOfStack &lt; currNumber =&gt; pop off the topOfStack</li><li>repeat this condition with currNumber until topOfStack is no longer smaller</li></ol><pre>/* psuedocode<br>for(currNum of temperatures){<br>  while(topOfStack &lt; currNum){<br>    stk.pop()<br>  }<br>  stk.push(currNum)<br>}<br>*/</pre><p>The problem here is that you don’t know the distance between the number you popped off and current number since you don’t know the index of the number you popped off.</p><p>Then I cheated and looked at part of a solution for the minutest minute</p><p><strong>I realized that they were storing the indices of the number and then referring to the temperature array to get the actual number for the comparison</strong></p><p>From here it was pretty simple! Also instead of using another array just use temperatures array for the distance (i — indexOfTopOfStack). This is possible cuz we never need the number we pop off.</p><p>Here is my solution :) As always let me know if any improvements can be made</p><pre>var dailyTemperatures = function(temperatures) {<br><br>    var stk = [0]<br><br>    for(var i = 1; i &lt; temperatures.length; i++){<br>        var topStackIndex = stk[stk.length-1] // last index of element of stack  <br>        while(temperatures[i] &gt; temperatures[topStackIndex]){<br>            // distance between the numbers<br>            temperatures[topStackIndex] = i - topStackIndex<br>            stk.pop()<br>            topStackIndex = stk[stk.length-1]         <br>        }<br>        stk.push(i)<br>    }<br>    // the leftover are values that do not have a larger number later <br>    while(stk.length &gt; 0){<br>        temperatures[stk[stk.length-1]] = 0<br>        stk.pop()<br>    }<br>    return temperatures<br><br><br>};</pre><p>Here is a picture that reminds me of fall girl 2014 tumblr… the simpler times when i never knew what leetcode was</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/0*OpMfKTIhTWiAroei.jpg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40f78df3a291" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[128. Longest Consecutive Sequence]]></title>
            <link>https://sravyadivakarla.medium.com/128-longest-consecutive-sequence-32ef906df52f?source=rss-6dd97d5e3702------2</link>
            <guid isPermaLink="false">https://medium.com/p/32ef906df52f</guid>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Sravya Divakarla]]></dc:creator>
            <pubDate>Mon, 16 Oct 2023 23:14:59 GMT</pubDate>
            <atom:updated>2023-10-16T23:17:09.596Z</atom:updated>
            <content:encoded><![CDATA[<p>Ofcourse you can solve this question with a simple sort and iteration.</p><ul><li>sort the array</li><li>iterate and keep track of the longest consecutive by checking if curr+1 exists and adding to maxLength</li></ul><p>This however is O(nlogn) and leetcode demands better!</p><p>Initially I thought of creating a map in which I store all the numbers and their positions. Then on each number I could have another while loop to check if there is a consecutive sequence:</p><pre>var longestConsecutive = function(nums) {<br><br>    /*<br>        hashmap of the num and position<br>        in loop check if num+1 is present and add to array<br>        have a max array and compare lengths<br>    */<br>    <br>    var m = new Map();<br>    var max = 0;<br>    for(var i = 0; i &lt; nums.length; i++){<br>        if(!m.has(nums[i])){<br>            m.set(nums[i], i)<br>        }<br>    }<br>    for(var i = 0; i &lt; nums.length; i++){<br>        var currLen = 1<br>        var next = nums[i]+1<br>        while(m.has(next)){<br>            next++<br>            currLen++<br>        }<br>        max = Math.max(currLen, max)<br>    }<br>    return max<br>};</pre><p>This worked on 69/74 cases</p><p>Leetcode demands BETTER!</p><p>There were two small tweeks</p><ol><li>use a set for unique nums</li><li>optimize the number of while loops needed to check the sequence</li></ol><p>The above code goes into the loop for all the following:</p><pre>nums = [100,4,200,1,3,2]<br>for i = 1: while loop checks 1-&gt;2-&gt;3-&gt;4<br>for i = 2: while loop checks 2-&gt;3-&gt;4<br>for i = 3: while loop checks 3-&gt;4</pre><p>To avoid this we need to find a pattern for the start of the sequence:</p><p>The start of the sequence is the only number that does not match</p><pre>!m.has(nums[i]-1 // there is no left element in the seq for the first num</pre><p>The new code is updated to:</p><pre>var longestConsecutive = function(nums) {<br><br>    var m = new Set(nums);<br>    var max = 0;<br>    <br>    for(var i = 0; i &lt; nums.length; i++){<br>        var currLen = 1<br>        var next = nums[i]+1<br>        if(!m.has(nums[i]-1)){<br>            while(m.has(next)){<br>                next++<br>                currLen++<br>            }<br>            max = Math.max(currLen, max)<br>        }<br>        <br>    }<br>    return max<br>};</pre><p>now go and try it for yourself and let me know if there are any more improvements I can make!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*mJNPzF0lRMnm_PExMLVlPw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32ef906df52f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[First Unique Character in a String]]></title>
            <link>https://sravyadivakarla.medium.com/first-unique-character-in-a-string-8191ffd0f0b8?source=rss-6dd97d5e3702------2</link>
            <guid isPermaLink="false">https://medium.com/p/8191ffd0f0b8</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[hackerrank]]></category>
            <category><![CDATA[interview-preparation]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Sravya Divakarla]]></dc:creator>
            <pubDate>Sun, 31 Jan 2021 07:26:03 GMT</pubDate>
            <atom:updated>2021-01-31T07:26:03.501Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sEtFJIITKJ0J8OL2CFmivg.png" /></figure><h4>Step 1:</h4><p>First you want to make a map with the key as the character and index as number of time the character occurs.</p><pre>var charCount = new Map();</pre><pre>for(var i = 0; i &lt; s.length; i++){<br>    var ch = s[i]; // get character</pre><pre>    //check if char exists in map &amp; inc count on occurrence<br>    if(charCount[ch]){ <br>       charCount[ch]++;<br>    }else charCount[ch]= 1 <br>}</pre><h4>Step 2 :</h4><p>Then, loop through the string again and reference the “charCount” map to check if it is a repeating ( &gt; 1) or non repeating (1) occurrence. The first character to have 1 as the char count value is the “First Unique Character”</p><pre>for(var i = 0; i &lt; s.length; i++){<br>    //find the first letter with a charCount of 1 (non repeating)<br>    var ch = s[i];<br>    if(charCount[ch] == 1){<br>        return i;<br>    }<br>};<br>return -1;</pre><p>Return index if character if found. Return -1 if not found or empty string.</p><h4>Full code:</h4><pre>var firstUniqChar = function(s) {<br>    <br>  var charCount = new Map();<br>  for(var i = 0; i &lt; s.length; i++){<br>      var ch = s[i];<br>      if(charCount[ch]){<br>        charCount[ch]++<br>      }else charCount[ch]= 1<br>  }</pre><pre>  for(var i = 0; i &lt; s.length; i++){<br>      //find the first letter with a charCount of 1 (non repeating)<br>      var ch = s[i];<br>      if(charCount[ch] == 1){<br>          return i;<br>      }<br>  };<br>  return -1; <br>    <br>};</pre><blockquote>Time complexity -&gt; O(n)</blockquote><blockquote>Space complexity -&gt; O(n)</blockquote><p>Problem: <a href="https://leetcode.com/problems/first-unique-character-in-a-string/">https://leetcode.com/problems/first-unique-character-in-a-string/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8191ffd0f0b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make your own portfolio website]]></title>
            <link>https://sravyadivakarla.medium.com/make-your-own-portfolio-website-9f0953b9742b?source=rss-6dd97d5e3702------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f0953b9742b</guid>
            <category><![CDATA[website]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[portfolio]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Sravya Divakarla]]></dc:creator>
            <pubDate>Thu, 31 Dec 2020 23:49:39 GMT</pubDate>
            <atom:updated>2020-12-31T23:49:39.819Z</atom:updated>
            <content:encoded><![CDATA[<p>Part 3</p><p>Start with code from Part 2 here: <a href="https://github.com/sravyasridivakarla/SimplePortfolioGuide">https://github.com/sravyasridivakarla/SimplePortfolioGuide</a></p><p>Project Page Design:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1AosC6YXveRdqgm8j7-X4g.png" /></figure><h3>Step 2: Project page</h3><h3>Background:</h3><p><strong>HTML skeleton:</strong></p><pre>&lt;div class = “page white”&gt;<br>  &lt;div class = “side-large white”&gt;<br>  &lt;/div&gt;<br>  &lt;div class = “side-small blue”&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>CSS:</p><p>We add overflow to the each page so that the divs inside are contained. Also for “side-small” and “side-large”, we want to have them positioned side by side. So we float each one to the left and set its width dimensions using “vw” measurement (view width) and its height dimensions using “vh” measurement (view height)</p><pre>.page{<br>  height: 100vh;<br>  /* add overflow to contain the divs*/<br>  overflow: hidden;<br>}<br>.blue{<br>  background-color: #E4F2F2;<br>}<br>.grey{<br>  background-color: grey;<br>}</pre><pre>.side-small{<br>  width:40vw;<br>  height:100vw;<br>  float:left;<br>}<br>.side-large{<br>  width: 60vw;<br>  height:100vw;<br>  float:left;<br>  /*parent of gray box is relative*/<br>  position: relative;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P0XpQGfkXxlA6fWxzHGXwQ.png" /></figure><h3>After adding boxes on top:</h3><p>HTML:</p><pre>&lt;div class = &quot;page white&quot;&gt;<br>  &lt;div class = &quot;side-large white&quot;&gt;<br>    &lt;div class = &quot;projectTextBox white absolute&quot;&gt;<br>      &lt;h1&gt; Project 1 &lt;/h1&gt;<br>      &lt;p&gt;Lorem ipsum dolor sit ...&lt;/p&gt;<br>    &lt;/div&gt;<br>    &lt;div class = &quot;projectImageBox grey absolute&quot;&gt;&lt;/div&gt;<br>  &lt;/div&gt;<br>  &lt;div class = &quot;side-small blue&quot;&gt;&lt;/div&gt;<br>&lt;/div&gt;</pre><p>CSS:</p><p>Here we play with the absolute and relative keywords to achieve the layering affect for the divs. The grey box is on top of the white and its top and left position is relative to the parent box “side-large”. Thats why “side-large” position is relative and “projectImageBox” and “projectImageBox” are absolute. This link helps to understand box positioning:</p><p><a href="https://www.freecodecamp.org/news/how-to-use-the-position-property-in-css-to-align-elements-d8f49c403a26/">https://www.freecodecamp.org/news/how-to-use-the-position-property-in-css-to-align-elements-d8f49c403a26/</a></p><pre>.page{<br>  height: 100vh;<br>  /* add overflow to contain the divs*/<br>  overflow: hidden;<br>}<br>.blue{<br>  background-color: #E4F2F2;<br>}<br>.grey{<br>  background-color: grey;<br>}</pre><pre>.side-small{<br>  width:40vw;<br>  height:100vw;<br>  float:left;<br>}<br>.side-large{<br>  width: 60vw;<br>  height:100vw;<br>  float:left;<br>  /*parent of gray box is relative*/<br>  position: relative;<br>}<br>.projectImageBox{<br>  height: 25%;<br>  width: 40%;<br>  top: 12%;<br>  left: 80%;<br>  position:absolute;<br>}<br>.projectTextBox{<br>  height: 25%;<br>  width: 40%;<br>  top: 12%;<br>  left: 20%;<br>  position:absolute;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fiH7oz1_0jcxmqqhPf6Zww.png" /></figure><h3>Page 2 : Alternate Design</h3><p>HTML:</p><pre>&lt;div class = “page white”&gt;<br>  &lt;div class = “side-small blue”&gt;<br>  &lt;/div&gt;<br>  &lt;div class = “side-large white”&gt;<br>    &lt;div class = “projectImageBox projectImageBox-left grey absolute”&gt;&lt;/div&gt;<br>    &lt;div class = “projectTextBox white absolute”&gt;<br>      &lt;h1&gt; Project 1 &lt;/h1&gt;<br>      &lt;p&gt;Lorem ipsum dolor ...&lt;/p&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>CSS:</p><p>Using the “.projectImageBox-left” class to just over right the positioning of grey image box so that it can go on the other side of the “side-large” div.</p><pre>.projectImageBox-left{<br>  left: -20%;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s1Qi4dS2ntTskih6QJXD7Q.png" /></figure><p>All code for each part published here: <a href="https://github.com/sravyasridivakarla/SimplePortfolioGuide">https://github.com/sravyasridivakarla/SimplePortfolioGuide</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f0953b9742b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make your own portfolio website]]></title>
            <link>https://sravyadivakarla.medium.com/make-your-own-portfolio-website-ce7b58b9e012?source=rss-6dd97d5e3702------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce7b58b9e012</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[portfolio]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Sravya Divakarla]]></dc:creator>
            <pubDate>Thu, 23 Jul 2020 05:08:26 GMT</pubDate>
            <atom:updated>2020-12-31T23:50:54.179Z</atom:updated>
            <content:encoded><![CDATA[<p>Part 2</p><p>Title page design:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B79MyW4xQwcj6b4chZ9ucQ.png" /></figure><h3>Step 2: Title page</h3><p><strong>HTML skeleton:</strong></p><pre>&lt;div class = &quot;page beige&quot; &gt;<br>  <br>  &lt;div&gt;<br>    &lt;h1&gt;Sravya Divakarla&lt;/h1&gt;<br>    &lt;div&gt;<br>      &lt;a&gt;Home&lt;/a&gt;<br>      &lt;a&gt;Contact&lt;/a&gt;<br>      &lt;a&gt;Projects&lt;/a&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>  <br>  &lt;div&gt;<br>    &lt;h1&gt;HEY THERE!&lt;/h1&gt;<br>    &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum&lt;/p&gt;<br>  &lt;/div&gt;</pre><pre>  &lt;div&gt; <br>  &lt;/div&gt;<br><br>&lt;/div&gt;</pre><p>Now lets add some styling to the title bar:</p><p><a href="https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_topnav_right"><strong>TITLE BAR</strong></a><strong>:</strong></p><pre>HTML:</pre><pre>&lt;div class = &quot;page beige&quot; &gt;<br>  &lt;div class = &quot;topnav&quot;&gt;<br>    &lt;h1 class=&quot;name&quot;&gt;Sravya Divakarla&lt;/h1&gt;<br>  &lt;div class = &quot;topnav-right&quot;&gt;<br>    &lt;a class=&quot;topElement&quot;&gt;Home&lt;/a&gt;<br>    &lt;a class=&quot;topElement&quot;&gt;Contact&lt;/a&gt;<br>    &lt;a class=&quot;topElement&quot;&gt;Projects&lt;/a&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>You want the name on the left and the links to the right. So make divs to separate the whole nav bar on top. Then we have all the links to the right in another div so we can keep those together.</p><pre>.topnav {<br>  font-family: sans-serif;<br>  overflow: hidden;<br>}<br>.name {<br>  float: left;<br>  text-align: center;<br>  padding: 14px 16px;<br>  font-size: 50px;<br>}<br>.topnav-right{<br>  float: right;<br>  font-size: 30px;<br>  text-align: center;<br>  padding: 70px 60px;<br>}<br>.topElement{<br>    padding: 30px<br>}</pre><p>The “topnav” class will make the the <a href="https://www.w3schools.com/cssref/tryit.asp?filename=trycss_overflow">overflow hidden</a>.</p><p>The name is <a href="https://www.w3schools.com/css/css_padding.asp">padded</a> left and the links are <a href="https://www.w3schools.com/css/css_padding.asp">padded</a> right</p><p><strong>CONTENT:</strong></p><p>There are several concepts for understanding how to make 2 divs go over each other like the design shows. Here is the code:</p><pre>HTML:</pre><pre>&lt;div class = &quot;imageBox grey absolute&quot;&gt; &lt;/div&gt;</pre><pre>&lt;div class = &quot;textbox&quot;&gt;<br>  &lt;h1&gt;HEY THERE!&lt;/h1&gt;<br>  &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum&lt;/p&gt;<br>&lt;/div&gt;<br></pre><pre>CSS:</pre><pre>.imageBox{<br>  height: 50vh;<br>  width: 60vw;<br>  top: 35vh;<br>  left: 35vh;<br>  position:absolute;<br>  background-color: grey;<br>}<br>        <br>.textbox {<br>  background-color: white;<br>  padding: 30px;<br>  width: 30vw;<br>  position:absolute;<br>  top: 25vh;<br>  left: 25vh;<br>}</pre><p><a href="https://www.w3schools.com/css/css_positioning.asp">Position</a> is set to absolute which means that the divs are being positioned relative to the page.</p><p><a href="https://www.w3schools.com/css/tryit.asp?filename=trycss_position_absolute">Top and left</a> give the position of the divs.</p><p>And Voila! You are done with your title page!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vXyK0MhqvVbWzguqri41Eg.png" /></figure><p>All code published here: <a href="https://github.com/sravyasridivakarla/SimplePortfolioGuide">https://github.com/sravyasridivakarla/SimplePortfolioGuide</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce7b58b9e012" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make your own portfolio website]]></title>
            <link>https://sravyadivakarla.medium.com/make-your-own-portfolio-website-d8452f8d1150?source=rss-6dd97d5e3702------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8452f8d1150</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[portfolio]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Sravya Divakarla]]></dc:creator>
            <pubDate>Thu, 23 Jul 2020 03:39:43 GMT</pubDate>
            <atom:updated>2020-07-23T03:39:43.353Z</atom:updated>
            <content:encoded><![CDATA[<p>PART 1</p><p>We first start with the design:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FLcBHnhC08GY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DLcBHnhC08GY&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/eacecc5eb5394321793a1a610c4e287a/href">https://medium.com/media/eacecc5eb5394321793a1a610c4e287a/href</a></iframe><p>Here is a look at how I made my website design:</p><h3><strong>Step 1: Make the pages</strong></h3><pre>HTML:</pre><pre>&lt;body&gt;<br>  &lt;div class = &quot;page beige&quot; &gt;&lt;/div&gt;<br>  &lt;div class = &quot;page white&quot; &gt;&lt;/div&gt;<br>  &lt;div class = &quot;page white&quot; &gt;&lt;/div&gt;<br>  &lt;div class = &quot;page white&quot; &gt;&lt;/div&gt;<br>  &lt;div class = &quot;page beige&quot; &gt;&lt;/div&gt;<br>&lt;/body&gt;<br></pre><pre>CSS:</pre><pre>body{<br>  margin: 0;<br>}<br>.page{<br>  height: 100vh;<br>}<br>.white{<br>  background-color: white;<br>}<br>.beige{<br>  background-color: #EFE3D7;<br>}</pre><p>The “page” class makes will make each page 100% of the view height.</p><p>The “white” and “beige” classes change the background color.</p><p>Body has a margin of 0 so that the background color has no gaps. (try deleting it and your color wont fill the whole page</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8452f8d1150" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[atoi]]></title>
            <link>https://sravyadivakarla.medium.com/atoi-20225605cb84?source=rss-6dd97d5e3702------2</link>
            <guid isPermaLink="false">https://medium.com/p/20225605cb84</guid>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Sravya Divakarla]]></dc:creator>
            <pubDate>Wed, 03 Jan 2018 00:47:58 GMT</pubDate>
            <atom:updated>2018-01-03T00:47:58.051Z</atom:updated>
            <content:encoded><![CDATA[<p>Leetcode : Implement atoi to convert a string to an integer.</p><p>Here is a good definition of atoi for C++11:</p><p><a href="http://en.cppreference.com/w/cpp/string/byte/atoi">std::atoi, std::atol, std::atoll - cppreference.com</a></p><p>After reading this, I write down the conditions I need to satisfy:</p><ol><li>Discard any whitespace until a non-whitespace character is read.</li><li>Then take in as many characters until it to form a valid integer number representation (no decimals)</li><li>Plus or minus sign must be considered (only once per string)</li><li>Overflow</li></ol><h4><em>1. Discard any whitespace until a non-whitespace character is read.</em></h4><pre>while(str[it] == &#39; &#39;) i++;     </pre><h4>2. Then take in as many characters until it to form a valid integer number representation</h4><pre>while(&#39;0&#39;&lt;= str[it] &amp;&amp; str[it] &lt;= &#39;9&#39;) <br>{<br>  num *= 10; //inc place of prev<br>  num += (str[it]-&#39;0&#39;); //char -&gt; int<br>  it++; <br>}</pre><h4>3. Plus or minus sign must be considered in front(only once per string)</h4><pre>//Before (2) loop after all white spaces read <br>int sign = 1;<br>while(str[it] == &#39; &#39;) i++;<br>if(str[it] == &#39;-&#39; ||str[it] == &#39;+&#39; ){<br>  if(str[it] == &#39;-&#39;) sign = -1;<br>  it++;<br>}</pre><p>Multiple the sign with final result.</p><h4>4. Overflow</h4><p>In the leetcode question they ask you to take care of overflow: If the correct value is out of the range of representable values, INT_MAX (2147483647) or INT_MIN (-2147483648) is returned.</p><pre>while(&#39;0&#39;&lt;= str[it] &amp;&amp; str[it] &lt;= &#39;9&#39;) <br>{<br>  num *= 10; //inc place of prev<br>  num += (str[it++]-&#39;0&#39;);<br>  if(num*sign &gt;= INT_MAX) return INT_MAX;<br>  if(num*sign &lt;= INT_MIN) return INT_MIN; <br>}</pre><h4>Final code:</h4><pre>int myAtoi(string str) {<br>        long num = 0;<br>        int it = 0;<br>        int sign = 1;<br>        <br>        //remove preceding whitespace<br>        while(str[it] == &#39; &#39;){<br>            it++; <br>        } <br>        // neg or positive<br>        if(str[it] == &#39;-&#39; ||str[it] == &#39;+&#39; ){<br>            if(str[it] == &#39;-&#39;) sign = -1;<br>            it++;<br>        }<br>        while(&#39;0&#39;&lt;= str[it] &amp;&amp; str[it] &lt;= &#39;9&#39;) <br>        {<br>            num *= 10; //inc place of prev<br>            num += (str[it++]-&#39;0&#39;);<br>            if(num*sign &gt;= INT_MAX) return INT_MAX;<br>            if(num*sign &lt;= INT_MIN) return INT_MIN; <br>        }<br>        return num*sign;<br>    }</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20225605cb84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integer to Roman]]></title>
            <link>https://sravyadivakarla.medium.com/integer-to-roman-4718058292a4?source=rss-6dd97d5e3702------2</link>
            <guid isPermaLink="false">https://medium.com/p/4718058292a4</guid>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Sravya Divakarla]]></dc:creator>
            <pubDate>Tue, 02 Jan 2018 22:38:16 GMT</pubDate>
            <atom:updated>2018-01-02T22:38:16.706Z</atom:updated>
            <content:encoded><![CDATA[<p>Leetcode: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.</p><p>Ones( I = 1 , 5 = V, 10 = X )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*Do8fFdXdepXyfgS_qA05qg.png" /></figure><p>Tens( X replaces I, L replaces V, C replaces X)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*gGJYBhOeQdgBcBw74_stQA.png" /></figure><p>Hundreds ( C replaces I, D (500) replaces V, M(1000) replaces X)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*mV02vqR8c0QYxGaVqamvXA.png" /></figure><p>Thousands (M replaces I)</p><p>So if there is an integer, we can break the number into Thousands, Hundreds, Tens and Ones and then replace them with roman numerals accordingly:</p><pre>1,264 = 1*1000 + 2*100 + 6*10 + 4 <br>      = I*1000 + II*100 + VI*10 + IV<br>      = M + CC + LX + IV<br>      = MCCLXIV</pre><p>1. To find the largest place value or the number of digits in the number:</p><pre>int numDigits = log10(num) + 1;</pre><p>The common logarithm of x is the power to which the number 10 must be raised to obtain the value x.</p><p>eg : log10(10) = 1 , log10(60) ~ 1.7, log10(100) = 2</p><p>2. To find the place value:</p><pre>int place = pow(10,(numDigits - 1));</pre><p>3. To get the first number of each place value in the number:</p><pre>int firstNum = num/place;</pre><p>4. To find the numeral associated with the number * place</p><p>Create a map with this table and then map it to the correct numeral:</p><pre>map&lt;int, char&gt; m = {{1, &#39;I&#39;}, {5, &#39;V&#39;},{10, &#39;X&#39;},{ 50, &#39;L&#39;},{100, &#39;C&#39;},{500, &#39;D&#39;},{1000, &#39;M&#39;}};</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/243/1*exRbBEN2yCRX8qV9WxZj2A.png" /></figure><p>4 and 9 have an exception of subtraction rule.</p><p>1 – 3 takes the 1 place numeral and repeats its the value number of times</p><p>5–8 adds 5’s numeral in that place and takes the 1 place numeral and repeats its the value number of times</p><pre>if(firstNum == 4){<br>  numeral += m[place]; <br>  numeral += m[place * 5];<br>}<br>else if(firstNum == 9){<br>  numeral += m[place];<br>  numeral += m[place * 10];<br>}<br>else{<br>  if(firstNum &gt; 4){<br>     numeral += m[place *5];<br>  }<br>  for(int i = 0; i &lt; firstNum%5; i++){<br>     numeral += m[place];                 <br>  }<br>}</pre><p>Then subtract the place * first num to go to the next place value:</p><pre>num -= firstNum*place;</pre><p>Full code:</p><pre>string intToRoman(int num) {<br>        map&lt;int, char&gt; m = {{1, &#39;I&#39;}, {5, &#39;V&#39;},{10, &#39;X&#39;},{ 50, &#39;L&#39;},{100, &#39;C&#39;},{500, &#39;D&#39;},{1000, &#39;M&#39;}};<br>        int numDigits = log10 (num) + 1;<br>        string numeral = &quot;&quot;;<br>        for(int i = 0; i &lt; numDigits ; i++){<br>            int place = pow(10,(numDigits - i - 1));<br>            int firstNum = num/place;<br>            if(firstNum == 4){<br>                numeral += m[place]; <br>                numeral += m[place * 5];<br>            }<br>            else if(firstNum == 9){<br>                numeral += m[place];<br>                numeral += m[place * 10];<br>            }<br>            else{<br>                if(firstNum &gt; 4){<br>                    numeral += m[place *5];<br>                }<br>                for(int i = 0; i &lt; firstNum%5; i++){<br>                    numeral += m[place];<br>                    <br>                }<br>            }    <br>           num -= firstNum*place;<br>        }<br>        return numeral;<br>    }</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4718058292a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>