<?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 Travis R. Redden on Medium]]></title>
        <description><![CDATA[Stories by Travis R. Redden on Medium]]></description>
        <link>https://medium.com/@TravisRedden?source=rss-4e31a6380526------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*D_cZLR9IfLvibtxnKPYqog.jpeg</url>
            <title>Stories by Travis R. Redden on Medium</title>
            <link>https://medium.com/@TravisRedden?source=rss-4e31a6380526------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 12:08:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@TravisRedden/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[Solving the “FizzBuzz Problem” in Typescript]]></title>
            <link>https://medium.com/@TravisRedden/solving-the-fizzbuzz-problem-in-typescript-c21ff4233034?source=rss-4e31a6380526------2</link>
            <guid isPermaLink="false">https://medium.com/p/c21ff4233034</guid>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[Travis R. Redden]]></dc:creator>
            <pubDate>Thu, 18 Jan 2024 01:19:25 GMT</pubDate>
            <atom:updated>2024-01-18T09:11:57.261Z</atom:updated>
            <content:encoded><![CDATA[<p>The FizzBuzz problem is a classic test often encountered in coding interviews. It’s a great way to demonstrate basic programming skills, particularly in control flow and conditional logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BMXTaysmoPpJ0TcoSDGWYg.png" /></figure><p>The problem statement is straightforward: Given an integer n, return a string array answer where each element corresponds to a number from 1 to n.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mJoUpmua8uZK84qloouAqg.png" /><figcaption>The constraint in this context, 1 &lt;= n &lt;= 10⁴, means that the solution is designed to handle any number ’n’ that is equal to or greater than 1 and equal to or less than 10,000.</figcaption></figure><p>For each number i:</p><ul><li>If i is divisible by both 3 and 5, answer[i] should be &quot;FizzBuzz&quot;.</li><li>If i is divisible only by 3, it should be &quot;Fizz&quot;.</li><li>If i is divisible only by 5, it should be &quot;Buzz&quot;.</li><li>Otherwise, answer[i] should be i as a string.</li></ul><p>Before diving into the solution, let’s understand the problem more deeply. It’s not just about checking divisibility; it’s about understanding how to structure your code to handle multiple conditions efficiently. This problem can be a trap for those who over-complicate things or miss out on the nuances of conditional logic.</p><p>When approaching this problem, it’s important to note the order of conditions. A common mistake is to check for divisibility by 3 and 5 separately, which can lead to incorrect outputs. The key is to start with the most specific condition (divisibility by both 3 and 5) and then move to the more general ones.</p><p>Let’s start by setting up a loop that iterates from 1 to n.</p><pre>function fizzBuzz(n: number): string[] {<br>   let answer: string[] = [];<br>    for (let i = 1; i &lt;= n; i++) {<br>      // Do Stuff<br>    }<br>    return answer;<br>};</pre><p>For each iteration, we’ll check the conditions in the order mentioned above and append the appropriate response to our answer array.</p><pre>function fizzBuzz(n: number): string[] {<br>   let answer: string[] = [];<br>    for (let i = 1; i &lt;= n; i++) {<br>        if (i % 3 === 0 &amp;&amp; i % 5 === 0) {<br>            answer.push(&quot;FizzBuzz&quot;);<br>        } else if (i % 3 === 0) {<br>            answer.push(&quot;Fizz&quot;);<br>        } else if (i % 5 === 0) {<br>            answer.push(&quot;Buzz&quot;);<br>        } else {<br>            answer.push(i.toString());<br>        }<br>    }<br>    return answer;<br>};</pre><p>In the solution above, we use a for loop to iterate over the range. The %, or “modulo”, operator checks for divisibility. We start by checking the combined condition for “FizzBuzz” and then move to the individual conditions for “Fizz” and “Buzz”. Finally, if none of the conditions are met, we convert the number to a string and add it to our array.</p><p>This problem is a great example of how simple logic, when properly structured, can solve an interesting challenge. It’s also a reminder of the importance of paying attention to detail in your conditional checks. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c21ff4233034" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving: The Group Anagrams Problem]]></title>
            <link>https://medium.com/@TravisRedden/solving-the-group-anagrams-problem-6a86f15375e0?source=rss-4e31a6380526------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a86f15375e0</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Travis R. Redden]]></dc:creator>
            <pubDate>Tue, 30 Aug 2022 09:33:45 GMT</pubDate>
            <atom:updated>2022-08-30T16:43:16.503Z</atom:updated>
            <content:encoded><![CDATA[<p>The Group Anagrams Problem is a commonly asked medium difficulty software engineering interview question. The prompt is challenging, but not to the point of inaccessibility as there are a number of ways that it can be solved. Its usually given as some variation of the following;</p><blockquote>Given an array of strings, group the anagrams together. You can return the answer in any order.</blockquote><p>But what <strong><em>is</em></strong> an anagram?</p><p>For those of us lucky enough to live through the 90s and early 00s an author by the name of J.K. Rowling introduced us to the perfect example, in the form of a dark wizard<em> “who must not be named.”</em></p><p>However, to the chagrin of any magical folk who may happen upon this article, for the sake of education, we must name him.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FEEFsJ-43pnA%3Fstart%3D35&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DEEFsJ-43pnA&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FEEFsJ-43pnA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a2f3df2a74e3fa30ac4609fdc51721b/href">https://medium.com/media/2a2f3df2a74e3fa30ac4609fdc51721b/href</a></iframe><p>When rearranged, the letters of the wizard’s name “Tom Marvolo Riddle” are revealed to spell out “I Am Lord Voldemort,” and thus millions of millennial children all over the world collectively learned the definition of an anagram.</p><blockquote>If you haven’t solved this problem before, I highly encourage you to step away from the article at this point and <a href="https://leetcode.com/problems/group-anagrams/">give it a shot</a> before continuing on to the solution below!</blockquote><p>Now that we understand what an anagram is, how do we go about solving this prompt? Step one is always, to diagram.</p><p>Why should we diagram first?</p><p>It helps us to visualize the data and how we want it to mutate, it also allows a space to collect our thoughts and plan our code rather than just jumping into a pool feet first without any idea how deep the water truly is. With this analogy in mind, consider diagramming your life vest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*McO_HyxTQ-u_AoUIBnja9A.png" /></figure><p>From a broad overview, the image above is what we want to accomplish. In addition to our input and output data we want to think about any constraints or edge cases we may encounter.</p><p>In this case, there are no constraints however our edge cases could include inputs without any anagrams, empty strings, anagrams with spaces, and anagrams with mismatched letter casing (uppercase vs lowercase). We’ll want to keep these in mind while we consider solutions.</p><p>So let’s think next steps, how can we group anagrams within an array?</p><p>We could try to find some commonality between them that we can exploit. Perhaps the most obvious example is that anagrams are comprised of the same letters.</p><p>Knowing that, maybe it would be a good idea to sort the letters in alphabetical order and store that as a key in an object, since we know that “eat” and “tea” for instance will share the same alphabetically organized key “aet”? The logic here is that, if we can get anagrams to share the same key, we might be able to find a way to push them into an array and store that array at the same key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gn5ClxCwpLYf4AWg84DtIg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pi_IwthsRCSSDDOCCccaSg.png" /></figure><p>We could then repeat that process <strong>for each</strong> of the indexes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*no28lfaJD37Sf00AYcXhog.png" /></figure><p>The final step would be to return an array of each of the value’s contained within the object.</p><p>Now that we have a pretty good understanding of what we want to do with the data, we can start thinking about executing our plan with pseudocode.</p><pre>var groupAnagrams = function (strs) {</pre><pre>// Create a new object to hold key, value pairs </pre><pre>// Create a result array</pre><pre>// for each index in input array<br>  // sort the letters<br>  // check if holder object has the sorted key<br>  // if it does<br>      // push original string to the array at the value<br>    // else<br>      // add sorted string to the object as a key, and assign its        <br>         value as the original string seated within an array</pre><pre>// Iterate over holder object and push anagram arrays to result<br>   array</pre><pre>// return result;</pre><pre>};</pre><p>With our pseudocode finished it’s time to start thinking about any native methods that might help us out. One tool that Javascript provides which could be helpful in our current predicament is the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map">Map object</a> which we could use to store our anagrams.</p><p>Map objects are collections of key value pairs that differ from traditional object literals in several important ways. We will, however, only be focusing on the few that apply to our current situation.</p><p>Maps are directly iterable, meaning they can be iterated over with a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of">for… of</a> loop, and contain many native methods including the following;</p><pre>.set() // sets a key value pair<br>.get() // retrieves the value at the given key<br>.has() // returns a boolean value indicating whether or not the map        <br>          contains an element with the specified key</pre><p>With these methods in mind, let’s take a look at our solution!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/660d9d017caaeec611387b0f2abdb323/href">https://medium.com/media/660d9d017caaeec611387b0f2abdb323/href</a></iframe><p>A note about .replaceAll(). This method isn’t supported in all browsers, you could instead use .replace(/ /g,&#39;&#39;) or .replace(/\s/g, &#39;&#39;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a86f15375e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving: The Reverse Integer Problem]]></title>
            <link>https://medium.com/@TravisRedden/solving-the-reverse-integer-problem-b7f151910614?source=rss-4e31a6380526------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7f151910614</guid>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Travis R. Redden]]></dc:creator>
            <pubDate>Fri, 29 Jul 2022 03:53:40 GMT</pubDate>
            <atom:updated>2022-07-29T14:31:03.349Z</atom:updated>
            <content:encoded><![CDATA[<p>The “Reverse Integer Problem” is a software engineering interview question commonly used in the hiring process, by some of the largest companies in the world, including Google, Adobe, Bloomberg, and Microsoft.</p><p>The problem is deceptively simple. It often reads as some variation of, “Given an integer, return the integer in reverse order.”</p><p>Simple, right?</p><p>Off the top of your head, you might be thinking of a simple solution in which you would create an array from the input integer, invoke the .reverse() and then .join() methods which will reverse the array and then join it back into a string, where you can then invoke the Number() method to return the now reversed integer.</p><pre>let integer = 123;</pre><pre>return Number(Array.from(integer.toString()).reverse().join(&#39;&#39;));</pre><p>but, if it were that easy we’d all be working at Google right now. The problem comes with a caveat in the form of a very simple constraint; You can not mutate the integer by changing it into a string or an array, and are only allowed math and integers in your solution code.</p><p>Yikes, this problem just got a lot more challenging. How then can we reverse a number using only javascript, and math?</p><p>The answer is actually kind of elegant.</p><blockquote>If you aren’t familiar with a solution to this problem I encourage you to take a break from reading and diagram out a couple of possibilities before continuing on to the solution below.</blockquote><p>The first step to solving a problem, is understanding the problem, and one of the best ways to understanding a problem is to draw it out.</p><p>Step one: IOCE! <br>What inputs, outputs, constraints and/or edge cases are we working with?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t5fBbIi24KLt8YlgxNkB2w.png" /></figure><p>Step two: Diagram<br>Now that we understand our inputs, outputs, constraints and edge cases we can begin to visualize how we want our data to behave in order to arrive at the requested output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mf3aqesaa4TONo8r3ZLInQ.png" /></figure><p>Step three: Translate to Code<br>So, the diagram looks nice and all but, how are we supposed to turn this into javascript without changing the input integer into a string or an array? If we look a little closer the answer begins to reveal itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P3MglWNM4QLwzsKumX06ug.png" /></figure><p>If we think of the top line as a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while">while loop</a> we can begin to understand it as…</p><blockquote>“while the input integer is greater than or equal to one…”</blockquote><pre>while (number &gt;= 1) {<br>  // do things<br>};</pre><p>We’ll next need to consider what we will do within the while loop to change the input ‘123’ to ‘12’ to ‘1’ and to hold on to that last element each time. We should see if there are any basic mathematical operations that could help.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*17G-_18H1Ksjj1HvydswQA.png" /></figure><p>The keen eyed observer may notice that (123 / 10) does not, in fact, equal 12 as the diagram implies, and instead comes out to a not so helpful, 12.3. Thankfully, javascript has a method for just this purpose. <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor">Math.floor</a>() will disregard any decimal places and return the largest integer less than or equal to the given number. In this case, turning an unhelpful 12.3, into a very helpful 12.</p><p>What about that other operator? input % 10 the percentage glyph is called the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Remainder">modulo operator</a>, sometimes referred to as the “remainder” operator, and can be read as “what is the largest remaining value after dividing the input by 10” or to put it more succinctly. Modulo can be thought of as running the following;</p><pre>let input = 123</pre><pre>input = Math.ceil(input / 10) // 13 (12.3 rounded up)</pre><pre>return (input - 10) // returns 3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ObBYeLVVnJWvtkWbEeZYCA.png" /></figure><p>Finally, the result of our modulo operation is multiplied by ten and added to the result of the next pass. (eg. (3 x 10) +2 followed by (32 x 10) + 1)</p><p>So then, the approach we’ll be using involves multiplication, division, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Remainder">the modulo (or remainder) operator</a> and a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while">while loop</a>. Let’s look at the final solution!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8d7e44e4b9d730e3076917a3e290439/href">https://medium.com/media/b8d7e44e4b9d730e3076917a3e290439/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7f151910614" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>