<?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: Joseph Louie</title>
    <description>The latest articles on DEV Community by Joseph Louie (@jolouie7).</description>
    <link>https://dev.to/jolouie7</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%2F269828%2F8badbdfd-e25a-44c6-8cb8-79120297f36b.jpg</url>
      <title>DEV Community: Joseph Louie</title>
      <link>https://dev.to/jolouie7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jolouie7"/>
    <language>en</language>
    <item>
      <title>Podcast Content Generator</title>
      <dc:creator>Joseph Louie</dc:creator>
      <pubDate>Mon, 25 Nov 2024 06:24:34 +0000</pubDate>
      <link>https://dev.to/jolouie7/podcast-content-generator-57e0</link>
      <guid>https://dev.to/jolouie7/podcast-content-generator-57e0</guid>
      <description>&lt;h1&gt;
  
  
  Building a Podcast Content Generator with AssemblyAI
&lt;/h1&gt;

&lt;p&gt;This is a submission for the &lt;a href="https://dev.to/challenges/assemblyai"&gt;AssemblyAI Challenge&lt;/a&gt;: No More Monkey Business.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;I built a web application that helps users quickly generate summaries from audio files. The app accepts audio uploads in various formats (MP3, WAV, OGG, M4A) and uses AssemblyAI's powerful API to transcribe and summarize the content.&lt;/p&gt;

&lt;p&gt;The application is built using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Next.js 14 with App Router&lt;/li&gt;
&lt;li&gt;TypeScript&lt;/li&gt;
&lt;li&gt;Tailwind CSS and Shadcn UI&lt;/li&gt;
&lt;li&gt;AssemblyAI API to transcribe and summarize the audio using AssemblyAI's Lemur API&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;You can find the source code for this project on &lt;a href="https://github.com/jolouie7/assemblyai-challenge" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here's how the application works:&lt;/p&gt;

&lt;h3&gt;
  
  
  Homepage of the application:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3qsvus8pmypfyk0tj9sp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3qsvus8pmypfyk0tj9sp.png" alt="Homepage" width="800" height="219"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  File Upload:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2t34a16h3w8dzdqguqvb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2t34a16h3w8dzdqguqvb.png" alt="File Upload" width="800" height="178"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  File summary generating key points:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6942wb46gqlahc3i8a1p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6942wb46gqlahc3i8a1p.png" alt="File Summary" width="800" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Journey
&lt;/h2&gt;

&lt;p&gt;Implementing this project was an exciting learning experience. Here's how I approached it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Frontend&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Built a responsive UI using Next.js and Tailwind CSS&lt;/li&gt;
&lt;li&gt;Implemented drag-and-drop file upload&lt;/li&gt;
&lt;li&gt;Created a loading state with a custom spinner component&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;AssemblyAI Integration&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set up secure API key handling using environment variables&lt;/li&gt;
&lt;li&gt;Implemented file upload and transcription using AssemblyAI's API&lt;/li&gt;
&lt;li&gt;Added error handling for various edge cases&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;User Experience&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Added visual feedback during file upload and processing&lt;/li&gt;
&lt;li&gt;Designed an intuitive summary display component&lt;/li&gt;
&lt;li&gt;Ensured mobile responsiveness&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Challenges and Solutions
&lt;/h3&gt;

&lt;p&gt;The main challenges I faced were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;File Upload Handling&lt;/strong&gt;: Implemented proper file validation and error handling&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API Integration&lt;/strong&gt;: Created a robust system for handling API responses and errors&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Future Improvements
&lt;/h3&gt;

&lt;p&gt;I plan to enhance the application with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User authentication system&lt;/li&gt;
&lt;li&gt;Saving and managing multiple summaries&lt;/li&gt;
&lt;li&gt;Additional customization options for the summary format&lt;/li&gt;
&lt;li&gt;Support for more file formats&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This project demonstrates the power of AssemblyAI's API. The combination of easy-to-use interface and powerful backend processing makes it a valuable tool for podcast producers and content creators.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>assemblyaichallenge</category>
      <category>ai</category>
      <category>api</category>
    </item>
    <item>
      <title>React Express NeonDB starter kit</title>
      <dc:creator>Joseph Louie</dc:creator>
      <pubDate>Mon, 02 Sep 2024 02:51:38 +0000</pubDate>
      <link>https://dev.to/jolouie7/react-express-neondb-starter-kit-3jpo</link>
      <guid>https://dev.to/jolouie7/react-express-neondb-starter-kit-3jpo</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/neon"&gt;Neon Open Source Starter Kit Challenge &lt;/a&gt;: Ultimate Starter Kit&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Technologies Used
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Frontend
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;React 18&lt;/li&gt;
&lt;li&gt;TypeScript&lt;/li&gt;
&lt;li&gt;Redux Toolkit&lt;/li&gt;
&lt;li&gt;React Router&lt;/li&gt;
&lt;li&gt;React Query&lt;/li&gt;
&lt;li&gt;Tailwind CSS&lt;/li&gt;
&lt;li&gt;Shadcn UI&lt;/li&gt;
&lt;li&gt;Axios&lt;/li&gt;
&lt;li&gt;Zod&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Backend
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Express&lt;/li&gt;
&lt;li&gt;Prisma&lt;/li&gt;
&lt;li&gt;PostgreSQL (via Neon)&lt;/li&gt;
&lt;li&gt;Passport JWT&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Link to Kit
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/jolouie7/react-express-neon-starter" rel="noopener noreferrer"&gt;https://github.com/jolouie7/react-express-neon-starter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F45aofpry6lk64epw4mps.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F45aofpry6lk64epw4mps.png" alt="Image description" width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Your Journey
&lt;/h2&gt;

&lt;p&gt;The technologies in this kit are modern with some older tried and true technologies in the backend.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>neonchallenge</category>
      <category>postgres</category>
      <category>database</category>
    </item>
    <item>
      <title>Best Time to Buy and Sell Stock in Python</title>
      <dc:creator>Joseph Louie</dc:creator>
      <pubDate>Sun, 03 Jan 2021 02:15:34 +0000</pubDate>
      <link>https://dev.to/jolouie7/best-time-to-buy-and-sell-stock-in-python-3pk7</link>
      <guid>https://dev.to/jolouie7/best-time-to-buy-and-sell-stock-in-python-3pk7</guid>
      <description>&lt;p&gt;You can find the leetcode problem &lt;a href="https://leetcode.com/problems/best-time-to-buy-and-sell-stock/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Question:
&lt;/h3&gt;

&lt;p&gt;Say you have an array for which the ith element is the price of a given stock on day i.&lt;/p&gt;

&lt;p&gt;If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit.&lt;/p&gt;

&lt;p&gt;Note that you cannot sell a stock before you buy one.&lt;/p&gt;

&lt;p&gt;Example 1:&lt;br&gt;
Input: [7,1,5,3,6,4]&lt;br&gt;
Output: 5&lt;br&gt;
Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5.&lt;br&gt;
             Not 7-1 = 6, as selling price needs to be larger than buying price.&lt;/p&gt;

&lt;p&gt;Example 2:&lt;br&gt;
Input: [7,6,4,3,1]&lt;br&gt;
Output: 0&lt;br&gt;
Explanation: In this case, no transaction is done, i.e. max profit = 0.&lt;/p&gt;
&lt;h3&gt;
  
  
  Brute Force Solution:
&lt;/h3&gt;

&lt;p&gt;I would use a nested for loop to compare a number and the other numbers to the right of it to find the max profit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;maxProfit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;max_profit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;earlier_price&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;later_price&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;earlier_price&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;profit&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;later_price&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;earlier_price&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                    &lt;span class="n"&gt;max_profit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;later_price&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;earlier_price&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;max_profit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'm updating the max_profit whenever I find a profit that is greater. For my for loops, I don't want to count the numbers to the left of the eariler_price and I don't want to double count the eariler_price. To prevent this I increased the beginning range by 1 (earlier_price + 1).&lt;/p&gt;

&lt;p&gt;If you copy and paste this solution into leetcode it will give you time exceeded because this algorithm runs in O(n^2) time and o(1) space. We are essentially looping through once for each number times all the other numbers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Optimal Solution:
&lt;/h3&gt;

&lt;p&gt;We are going to keep track of the max_profit and the minimum number that we have seen so far. We are going to loop through each number in the list, and see if there is a lower number than our minimum_num. If there is, we reassign the minimum_num. We also decide if the max_profit stays the same or if we reassign it with our new calculated profit. This algorithm doesn't make new space and only goes through the list once.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;maxProfit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;max_profit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="n"&gt;minimum_num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100000&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;minimum_num&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;minimum_num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt;
            &lt;span class="n"&gt;max_profit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_profit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;minimum_num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;max_profit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might be wondering why is our minimum_num so high? Where did you get this number from? This is a very high number I set because if I were to set the minimum_num to be 0, then it might be lower than anything in our list. You could also set the minimum_num to the first number in the list too. The minimum_num will most likely be replaced in the first iteration of our loop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;max_profit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_profit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;minimum_num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I believe this is the most important step in this algorithm because it's where you decide whether to update max_profit or not.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;This algorithm uses the Greedy Approach, which says that we are going to have a variable/variables that we will update as we find something better.&lt;/p&gt;

&lt;p&gt;Thank You for reading!&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Divide and Conquer</title>
      <dc:creator>Joseph Louie</dc:creator>
      <pubDate>Fri, 11 Dec 2020 21:56:54 +0000</pubDate>
      <link>https://dev.to/jolouie7/divide-and-conquer-5cid</link>
      <guid>https://dev.to/jolouie7/divide-and-conquer-5cid</guid>
      <description>&lt;p&gt;Divide and Conquer is a popular algorithm technique normally used on an array/list. The idea is to divide the list in half until you find your target or left &amp;lt;= right condition is not met. This reference will mainly be for reference for those who don't remember how binary search works.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;binary_search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
  &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

  &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
      &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below shows how binary search would work with an odd number of elements in the list.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6juqufae7zkx5hg3ci4q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6juqufae7zkx5hg3ci4q.png" alt="odd list" width="261" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below shows how binary search would work with an even number of elements in the list.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: With an even number of elements we pick the left element instead of the right.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl2ofp5nkbgfplnnj2ho9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl2ofp5nkbgfplnnj2ho9.png" alt="even list" width="345" height="642"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank You for reading! I'm hoping to do this for more algorithm patterns.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>beginners</category>
      <category>python</category>
    </item>
    <item>
      <title>My favorite place to look for icons</title>
      <dc:creator>Joseph Louie</dc:creator>
      <pubDate>Mon, 30 Nov 2020 04:17:35 +0000</pubDate>
      <link>https://dev.to/jolouie7/my-favorite-place-to-look-for-icons-5dh</link>
      <guid>https://dev.to/jolouie7/my-favorite-place-to-look-for-icons-5dh</guid>
      <description>&lt;p&gt;When I'm working with react I would go to fontawesome to look for a nice icon. I would try to make it work in my react app but somehow, it just won't work. I found this site that seemed like it was made for react apps. It's currently my favorite site to get icons. It has all kinds of styles for icons too.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://react-icons.github.io/react-icons/" rel="noopener noreferrer"&gt;React Icons&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This site has saved me a lot of headaches. It uses icon components similar to how you would import another file you wrote in react.&lt;/p&gt;

&lt;p&gt;Thank You for reading my short post! Have you heard of React Icons? Do you have another favorite icons site? Let me know in the comments!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>My experience using AWS S3 and Multer to upload a photo</title>
      <dc:creator>Joseph Louie</dc:creator>
      <pubDate>Sat, 21 Nov 2020 06:17:25 +0000</pubDate>
      <link>https://dev.to/jolouie7/my-experience-using-aws-s3-and-multer-to-upload-a-photo-3j7i</link>
      <guid>https://dev.to/jolouie7/my-experience-using-aws-s3-and-multer-to-upload-a-photo-3j7i</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This is a single file upload only&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;While creating my Medium clone called Freemium, I decided I want to have a photo upload feature because I've never implemented that feature before. I specifically wanted to use AWS because that's what most companies want here in the bay area. I knew that I wanted to use S3 because that was AWS's file storage system.&lt;/p&gt;

&lt;h3&gt;
  
  
  What I wanted to happen
&lt;/h3&gt;

&lt;p&gt;I first went on Youtube and looked at a couple of videos on what it might look like uploading photos from my node.js backend to S3. There were many videos of people using node.js to upload to S3 and there were many videos of people using react to upload to S3, but it was kind of hard to find anything that used react -&amp;gt; node.js -&amp;gt; S3. After implementing node.js -&amp;gt; S3 I tried to create a simple react.js frontend to hit my backend but nothing worked. It could have been because I was using redux action creators to hit my backend but I'm not sure. &lt;/p&gt;

&lt;h3&gt;
  
  
  How did I go about learning AWS S3?
&lt;/h3&gt;

&lt;p&gt;There were 2 articles that stood out to me that I've tried and were up to date.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://medium.com/@fabianopb/upload-files-with-node-and-react-to-aws-s3-in-3-steps-fdaa8581f2bd" rel="noopener noreferrer"&gt;Here is an article by Fabiano&lt;/a&gt;. He has revised his article with typescript in mind.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://levelup.gitconnected.com/file-upload-express-mongodb-multer-s3-7fad4dfb3789" rel="noopener noreferrer"&gt;File Upload — Express, MongoDB, Multer &amp;amp; S3 by Tyler Knapp&lt;/a&gt;. This article was the one I used and worked for me. He also has a post for a react frontend but it's pretty simple. You can find that at the bottom of this article. The only concern I have with his way is that he uses Multer S3 which by the looks of it, hasn't had any commits in 2 years. That's a long time.
&amp;gt; In his post he has standard CORS settings but it doesn't work now, maybe because amazon updated their input requirement. They want your CORS to be JSON. Here's what I used:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET",
            "PUT",
            "POST",
            "HEAD"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [],
        "MaxAgeSeconds": 3000
    }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the Bucket Policy that worked for me&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicRead",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::&amp;lt;YOUR BUCKET NAME&amp;gt;/*"
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;I have my Block public access turned off. You can enable it but I think you might have to configure and look for how to deal with signed URLs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  An issue I ran into when I went to test the photo upload on a live site.
&lt;/h3&gt;

&lt;p&gt;When I manually tested the file upload feature it didn't work. This is the error I got:&lt;br&gt;
"The request signature we calculated does not match the signature you provided. Check your key and signing method."&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After an hour of googling I figured that it was either:&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;There was an extra character I didn't expect in my key&lt;/li&gt;
&lt;li&gt;I had to include a request header that I was missing&lt;/li&gt;
&lt;li&gt;I wasn't allowing my frontend access to my backend aka. CORS&lt;/li&gt;
&lt;li&gt;I just needed new keys&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I tested every one of the problems in that order and after seeing a GitHub forum post of a comment with 20+ thumbs up saying "I just generated new keys", I tried it and it worked. I didn't believe this would work because my keys were only a week old. My new keys were longer than my old keys though.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Sidenote: other resources I used worked for node.js -&amp;gt; AWS S3, maybe if I didn't use a redux action to try to hit my backend then maybe it might have worked. I can link the resources I think might have worked in the post if anyone wants to know.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thank You for reading! Comment down below what resources worked for you. &lt;/p&gt;

&lt;p&gt;Check out my Medium Clone. &lt;a href="https://github.com/jolouie7/free_medium-reactjs" rel="noopener noreferrer"&gt;Link Here to view Freemium&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>node</category>
      <category>react</category>
    </item>
    <item>
      <title>Controlled Form Inputs using React hooks</title>
      <dc:creator>Joseph Louie</dc:creator>
      <pubDate>Sun, 15 Nov 2020 03:05:21 +0000</pubDate>
      <link>https://dev.to/jolouie7/controlled-form-inputs-using-react-hooks-1b05</link>
      <guid>https://dev.to/jolouie7/controlled-form-inputs-using-react-hooks-1b05</guid>
      <description>&lt;h3&gt;
  
  
  Why do you need Controlled Forms?
&lt;/h3&gt;

&lt;p&gt;One reason why someone might use controlled inputs is to validate the input before submission. &lt;/p&gt;

&lt;h3&gt;
  
  
  The overall process of now controlled inputs work
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;user types -&amp;gt; calls handleChange -&amp;gt; sets the data based on the name&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;NOTE: setName/setUsername/etc are async&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  An example of how to implement controlled inputs in react hooks
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./styles.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Where our state is being stored&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setUsername&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setEmail&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setPassword&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Everytime input changes we update the state&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleChange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;username&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setUsername&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setPassword&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleSubmit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;username: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// The value will be based on the state&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Controlled&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="nx"&gt;onSubmit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleSubmit&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;
            &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleChange&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/input&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;
            &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;username&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleChange&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/input&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;
            &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleChange&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/input&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;
            &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleChange&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/input&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Submit&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Thank You for reading! I know that the part where we update the state can be improved to be more DRY, but I just find that the if-else statements make it easy to understand. If you have a better way to implementing that part let me know in the comments. This is usually what I would use when I implement a controlled form input.&lt;/p&gt;

</description>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>First week of November plans</title>
      <dc:creator>Joseph Louie</dc:creator>
      <pubDate>Tue, 03 Nov 2020 01:31:47 +0000</pubDate>
      <link>https://dev.to/jolouie7/first-week-of-november-plans-5a43</link>
      <guid>https://dev.to/jolouie7/first-week-of-november-plans-5a43</guid>
      <description>&lt;h3&gt;
  
  
  What I'm working on
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;I've enjoyed the idea of cloning things as projects to put on your portfolio. Some advantages of cloning an existing site are you don't have to think about the UI too much, you have ideas of what functionality to include, and there might be other clone projects you can reference. With that being said, I've been working on a medium clone, something like &lt;a href="https://github.com/gothinkster/realworld" rel="noopener noreferrer"&gt;Conduit&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;For this project, I'm planning to use the MERN stack with redux and typescript.&lt;/li&gt;
&lt;li&gt;I've already built out a lot of the auth for the web app, so I'm excited to build the core functionality for the medium clone. I'll be updating my progress through blog posts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Experience job hunting
&lt;/h3&gt;

&lt;p&gt;My experience with the job hunt hasn't been the best, but I'm determined to find out what my problem is. My current issue right now has been that I haven't been getting many interviews. I think this could be because of my portfolio, it might not be strong enough. I'm hoping that using typescript to build the medium clone will put me on some people's radar.&lt;/p&gt;

&lt;p&gt;Thank You for reading! Let me know what you're working on, what worked and what didn't work for you during the job hunt, or your experience learning/using typescript.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>webdev</category>
      <category>welcome</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Starting to blog again</title>
      <dc:creator>Joseph Louie</dc:creator>
      <pubDate>Mon, 02 Nov 2020 03:27:28 +0000</pubDate>
      <link>https://dev.to/jolouie7/starting-to-blog-again-1317</link>
      <guid>https://dev.to/jolouie7/starting-to-blog-again-1317</guid>
      <description>&lt;p&gt;Hi, my name is Joseph. I have been job hunting for a couple of months now after finishing my coding Bootcamp, and I can't say it has been easy. There are many days where I don't feel motivated to program and flat out depressed at all the rejection letters I get. If you're in the same situation as me, keep trying! Find something that will motivate you to program.&lt;/p&gt;

&lt;p&gt;Let's get into the reason for my title. Yesterday, I came across a podcast by FreeCodeCamp. They did an episode on Shawn Wang aka. SWYX. I've been in the ReactJs subreddit for a long time so I've seen him a lot while browsing the subreddit. He is a self-taught developer who made the transition from the world of finance to software development at the age of 30.&lt;/p&gt;

&lt;p&gt;Here's the episode if you want to listen to it. &lt;a href="https://www.freecodecamp.org/news/shawn-wang-podcast-interview/" rel="noopener noreferrer"&gt;Podcast: Leaving a $350K/year job to learn coding - Shawn Wang interview.&lt;/a&gt; Be warned that it's kind of long (2hours). &lt;/p&gt;

&lt;p&gt;The main talking points that I got from the episode were, he encourages others to do "No Zero Days" and "Learn in Public". &lt;/p&gt;

&lt;h3&gt;
  
  
  No Zero Days
&lt;/h3&gt;

&lt;p&gt;What do those mean? "No Zero Days", is what I think of as doing something that will bring you one step closer to the developer you dream to be. This could be something simple like writing down a todo list of all the features you want in your project you're currently working on. Do something every day and you will be surprised at what you can accomplish. Just have something to get the ball rolling, because once it starts rolling it will be hard to stop!&lt;/p&gt;

&lt;h3&gt;
  
  
  Learn in Public
&lt;/h3&gt;

&lt;p&gt;"Learn in Public", is just as it sounds. Most of us, me included don't blog, don't tweet, don't answer/ask questions on StackOverflow, don't participate in Reddit discussions. Let's say for example that you blog about something that you have learned recently. Others may take notice and thank you for your valuable insight. Maybe, no one reads your post, that's fine! If no one reads your post you can have something to refer back to when you forget something. Who knows you may have a React problem and the React genius himself Dan Abramov might come by to give you some help. You might be asking yourself, "what if I'm wrong?". That's okay! Shawn talks about how if you put in the effort and try to output good content, even if your wrong people will chime in to correct you. &lt;/p&gt;

&lt;p&gt;As the last point, if anything blog, create youtube videos, tweet, create a cheat sheet for yourself.&lt;/p&gt;

&lt;p&gt;Thank you for reading! I'll be sure to practice Learn in Public when I can. Let me know in the comments if you've seen this episode or what are your thoughts on Learn in Public?&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://gist.github.com/sw-yx/9720bd4a30606ca3ffb8d407113c0fe5" rel="noopener noreferrer"&gt;How to get started with Learn in Public&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>career</category>
    </item>
    <item>
      <title>Why you shouldn't spend too much time on 1 Leetcode problem</title>
      <dc:creator>Joseph Louie</dc:creator>
      <pubDate>Mon, 22 Jun 2020 00:48:07 +0000</pubDate>
      <link>https://dev.to/jolouie7/why-you-shouldn-t-spend-too-much-time-on-1-leetcode-problem-5ajh</link>
      <guid>https://dev.to/jolouie7/why-you-shouldn-t-spend-too-much-time-on-1-leetcode-problem-5ajh</guid>
      <description>&lt;p&gt;When practicing Leetcode problems if you can't figure out the solution in 20 minutes you should probably look at the solution. Some people may disagree with me on this. Why I think you should quit after 20 minutes is because if you can't figure out how to solve the problem after this amount of time you won't be able to figure it out with a couple more minutes. If you do come up with a solution is might not be the most optimized solution. Looking at the solution you can figure out how to get to the optimized solution. You might even have figured out a technique that you didn't know before. Don't spend too much time looking at the solution but do understand it. How did the solver get to the final solution? Doing this over and over again will expose you to a lot of problems. Hopefully later on you will recognize the question or technique you need to solve the problem. &lt;/p&gt;

&lt;p&gt;Exposing yourself to many problems is better than understanding the 1 problem in depth. You want to understand how to solve many different problems not just that 1 problem. You only have a limited amount of time until your interview or until someone asks you for an interview.&lt;/p&gt;

&lt;p&gt;Thank you for reading.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>My first attempt at using python's selenium</title>
      <dc:creator>Joseph Louie</dc:creator>
      <pubDate>Sat, 13 Jun 2020 07:58:50 +0000</pubDate>
      <link>https://dev.to/jolouie7/my-first-attempt-at-using-python-s-selenium-3ogl</link>
      <guid>https://dev.to/jolouie7/my-first-attempt-at-using-python-s-selenium-3ogl</guid>
      <description>&lt;ul&gt;
&lt;li&gt;This post below will be about what my experience was like using python's selenium. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Reason for wanting to learn selenium in the first place
&lt;/h3&gt;

&lt;p&gt;I love automation, it's really cool when you can become more productive by allowing a bot to do repetitive work for you. I had a great project idea that I wanted to implement that involved selenium and youtube. In my subscription feed I had channels where i would watch all their videos everyday. Everyday I would add the videos to either a watch later playlist or add it to queue. I wanted a way for a program to do this for me.&lt;/p&gt;

&lt;h3&gt;
  
  
  Results of using selenium
&lt;/h3&gt;

&lt;p&gt;The selenium docs are pretty clear and straight forward. My first task was to setup selenium and chrome webderiver. This took some time because I had to configure the path to my downloaded chrome webdriver and set a path to my chrome location. If you have your chrome in it's default location (where it usually would be when you finish downloading it) this wouldn't be a problem for you. After configuration, I was able to open a site using selenium. I soon realized that I couldn't sign in to google because google was protecting my account from selenium. I scrapped my project idea, but it was fun just openning up a website page automatically. &lt;/p&gt;

&lt;h3&gt;
  
  
  Future
&lt;/h3&gt;

&lt;p&gt;In the future I plan to use selenium for testing, a new project, or some simple task where I click something everyday.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=Xjv1sY630Uc" rel="noopener noreferrer"&gt;Resource I used to setup and use Selenium&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Merge Two Sorted Lists in Python</title>
      <dc:creator>Joseph Louie</dc:creator>
      <pubDate>Thu, 04 Jun 2020 05:17:06 +0000</pubDate>
      <link>https://dev.to/jolouie7/merge-two-sorted-lists-in-python-3gm7</link>
      <guid>https://dev.to/jolouie7/merge-two-sorted-lists-in-python-3gm7</guid>
      <description>&lt;p&gt;Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing together the nodes of the first two lists.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input: 1 -&amp;gt; 2 -&amp;gt; 4, 1 -&amp;gt; 3 -&amp;gt; 4
Output: 1 -&amp;gt; 1 -&amp;gt; 2 -&amp;gt; 3 -&amp;gt; 4 -&amp;gt; 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Approach
&lt;/h3&gt;

&lt;p&gt;We get 2 linked lists. l1 and l2 we can consider as the head of their own lists. There are many approaches to this but in this blog we are going to create a new list node and return that. We go through our 2 linked lists and compare the heads. Our new list node will then reference the lower node of the 2. If they are both the same it doesn't matter which one we reference. Once we finish a list we will just reference the rest of the other list. We know a list is finished once it hits None value. Couple things we have to be aware of is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We are using a dummy variabe to create our new list node&lt;/li&gt;
&lt;li&gt;We need to keep track of the head, which is why we create 2 list nodes&lt;/li&gt;
&lt;li&gt;We need to move l1 and l2 pointers (heads) accordingly&lt;/li&gt;
&lt;li&gt;We have to move our dummy pointer everytime we reference a node&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Solution
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;mergeTwoLists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ListNode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ListNode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ListNode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# We create a new linked list with dummy being the head.
&lt;/span&gt;        &lt;span class="c1"&gt;# 0 is just a val i assign, anything &amp;lt; 1 is fine
&lt;/span&gt;        &lt;span class="n"&gt;dummy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ListNode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dummy&lt;/span&gt;

        &lt;span class="c1"&gt;# While niether list has reached the end
&lt;/span&gt;        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="c1"&gt;# we compare the pointers to see which one is lower
&lt;/span&gt;          &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# dummy node points to the next node, which this case is l1
&lt;/span&gt;            &lt;span class="n"&gt;dummy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt;
            &lt;span class="c1"&gt;# move the pointer at l1 forward
&lt;/span&gt;            &lt;span class="n"&gt;l1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;
          &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;dummy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt;
            &lt;span class="n"&gt;l2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;
          &lt;span class="c1"&gt;# reassign dummy pointer to keep up with the newly referenced nodes
&lt;/span&gt;          &lt;span class="n"&gt;dummy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dummy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;
        &lt;span class="c1"&gt;# When one list reaches the end
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="c1"&gt;# Add the rest of the nodes from l2
&lt;/span&gt;          &lt;span class="c1"&gt;# This works becasue each node has a reference to it's next node
&lt;/span&gt;          &lt;span class="n"&gt;dummy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="n"&gt;dummy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt;
        &lt;span class="c1"&gt;# we don't want to return None or our default val. Return val after none
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;One thing to note about linked lists is that a head and a linked list is synonymous&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  We are not creating any new nodes besides our dummy node and head node. Everything I do below is just referencing (AKA node pointing to another node).
&lt;/h1&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Step by Step Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# l1: 1 -&amp;gt; 2 -&amp;gt; 4 -&amp;gt; None
# l2: 1 -&amp;gt; 3 -&amp;gt; 4 -&amp;gt; None
# dummy: 0
&lt;/span&gt;         &lt;span class="o"&gt;^&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;1st iteration&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# l1: 1 -&amp;gt; 2 -&amp;gt; 4 -&amp;gt; None
&lt;/span&gt;      &lt;span class="o"&gt;^&lt;/span&gt;
&lt;span class="c1"&gt;# l2: 1 -&amp;gt; 3 -&amp;gt; 4 -&amp;gt; None
&lt;/span&gt;           &lt;span class="o"&gt;^&lt;/span&gt;
&lt;span class="c1"&gt;# dummy: 0 -&amp;gt; 1
&lt;/span&gt;              &lt;span class="o"&gt;^&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2nd iteration&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# l1: 1 -&amp;gt; 2 -&amp;gt; 4 -&amp;gt; None
&lt;/span&gt;           &lt;span class="o"&gt;^&lt;/span&gt;
&lt;span class="c1"&gt;# l2: 1 -&amp;gt; 3 -&amp;gt; 4 -&amp;gt; None
&lt;/span&gt;           &lt;span class="o"&gt;^&lt;/span&gt;
&lt;span class="c1"&gt;# dummy: 0 -&amp;gt; 1 -&amp;gt; 1
&lt;/span&gt;                   &lt;span class="o"&gt;^&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3rd iteration&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# l1: 1 -&amp;gt; 2 -&amp;gt; 4 -&amp;gt; None
&lt;/span&gt;                &lt;span class="o"&gt;^&lt;/span&gt;
&lt;span class="c1"&gt;# l2: 1 -&amp;gt; 3 -&amp;gt; 4 -&amp;gt; None
&lt;/span&gt;           &lt;span class="o"&gt;^&lt;/span&gt;
&lt;span class="c1"&gt;# dummy: 0 -&amp;gt; 1 -&amp;gt; 1 -&amp;gt; 2
&lt;/span&gt;                        &lt;span class="o"&gt;^&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4th iteration&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# l1: 1 -&amp;gt; 2 -&amp;gt; 4 -&amp;gt; None
&lt;/span&gt;                &lt;span class="o"&gt;^&lt;/span&gt;
&lt;span class="c1"&gt;# l2: 1 -&amp;gt; 3 -&amp;gt; 4 -&amp;gt; None
&lt;/span&gt;                &lt;span class="o"&gt;^&lt;/span&gt;
&lt;span class="c1"&gt;# dummy: 0 -&amp;gt; 1 -&amp;gt; 1 -&amp;gt; 2 -&amp;gt; 3
&lt;/span&gt;                             &lt;span class="o"&gt;^&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5th iteration&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# l1: 1 -&amp;gt; 2 -&amp;gt; 4 -&amp;gt; None
&lt;/span&gt;                &lt;span class="o"&gt;^&lt;/span&gt;
&lt;span class="c1"&gt;# l2: 1 -&amp;gt; 3 -&amp;gt; 4 -&amp;gt; None
&lt;/span&gt;                      &lt;span class="o"&gt;^&lt;/span&gt;
&lt;span class="c1"&gt;# dummy: 0 -&amp;gt; 1 -&amp;gt; 1 -&amp;gt; 2 -&amp;gt; 3 -&amp;gt; 4
&lt;/span&gt;                                  &lt;span class="o"&gt;^&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;break out of while loop&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# l1: 1 -&amp;gt; 2 -&amp;gt; 4 -&amp;gt; None
&lt;/span&gt;                &lt;span class="o"&gt;^&lt;/span&gt;
&lt;span class="c1"&gt;# l2: 1 -&amp;gt; 3 -&amp;gt; 4 -&amp;gt; None
&lt;/span&gt;                      &lt;span class="o"&gt;^&lt;/span&gt;
&lt;span class="c1"&gt;# dummy: 0 -&amp;gt; 1 -&amp;gt; 1 -&amp;gt; 2 -&amp;gt; 3 -&amp;gt; 4 -&amp;gt; 4
&lt;/span&gt;                                  &lt;span class="o"&gt;^&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If there were more nodes after the second 4 you would get references to those nodes becasue the second 4 is going to point to another node. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Return the head which is first 1&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let me know how you liked the blog. If anything is wrong please feel free to comment below or message me directly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://leetcode.com/problems/merge-two-sorted-lists/" rel="noopener noreferrer"&gt;Problem on Leetcode&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=K63Mjf-H0B0" rel="noopener noreferrer"&gt;Video solution in Java by Kevin Naughton Jr.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
    </item>
  </channel>
</rss>
