<?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 Wenhan Wang on Medium]]></title>
        <description><![CDATA[Stories by Wenhan Wang on Medium]]></description>
        <link>https://medium.com/@yuoiobest?source=rss-f3d5662696b0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*j6kqETU8jc8b5oJa.</url>
            <title>Stories by Wenhan Wang on Medium</title>
            <link>https://medium.com/@yuoiobest?source=rss-f3d5662696b0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 13:48:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yuoiobest/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[Thoughts about a two pointer array problem — #27 LeetCode]]></title>
            <link>https://medium.com/@yuoiobest/thoughts-about-a-two-pointer-array-problem-27-leetcode-d3fc891b28eb?source=rss-f3d5662696b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3fc891b28eb</guid>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Wenhan Wang]]></dc:creator>
            <pubDate>Tue, 09 Jul 2019 16:44:05 GMT</pubDate>
            <atom:updated>2019-07-09T16:46:14.075Z</atom:updated>
            <content:encoded><![CDATA[<h3>Thoughts about a two pointer array problem — #27 LeetCode</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hbMDwSm8OCjQM3Zt" /><figcaption>Photo by <a href="https://unsplash.com/@raduflorin?utm_source=medium&amp;utm_medium=referral">Radu Florin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Please check the link first for the details of the problem.</p><p><a href="https://leetcode.com/problems/remove-element/">Remove Element - LeetCode</a></p><blockquote>“ Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with **O(1)** extra memory. The order of elements can be changed. It doesn’t matter what you leave beyond the new length.</blockquote><blockquote>Given `nums = [3,2,2,3], val = 3`, your function should return length = 2, with the first two elements of `nums` being 2. It doesn’t matter what you leave beyond the returned length.”</blockquote><p>The first thought to this problem was a naive solution — to create another array for *filtered* values. However, under the requirement of memory usage. We have to modify the input array in place.<br>The output should be a number N which represents the *valid length* of the array, which means the first N elements should not have the `val`.</p><p>I decided to use two pointer method to solve this problem. <br>- [ ] Why?<br>With two pointers `index`, `targetIndex`, `index` representing the index of `nums` loop function and `targetIndex` representing the result array index which starts from 0. Imagine you are operating a new array based on the original array, you are just moving the qualified values forward into the new array.<br>In the loop of `nums`, if `nums[index]` is not equal to `val`, we move the values to the new array, `nums[targetIndex] = nums[index]` and increment the `targetIndex` by 1 to expand the new array. If `nums[index]`is equal to `val` we just skip the the value movement, so the new array will only include the qualified values.</p><p>```javascript<br>/**<br> * <a href="http://twitter.com/param">@param</a> {number[]} nums<br> * <a href="http://twitter.com/param">@param</a> {number} val<br> * <a href="http://twitter.com/return">@return</a> {number}<br> */<br>var removeElement = function(nums, val) {<br> const arrLength = nums.length;<br> if (arrLength === 0)<br> return 0;<br> let targetIndex = 0;<br> for(let index = 0; i &lt; arrLength; index++) {<br> if (nums[index] !== val)<br> nums[targetIndex++] = nums[index];}<br> return targetIndex;<br>};<br>```</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3fc891b28eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What I learned from my first week of work]]></title>
            <link>https://medium.com/@yuoiobest/what-i-learned-from-my-first-week-of-work-ea87f608cc73?source=rss-f3d5662696b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea87f608cc73</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[mongoose]]></category>
            <dc:creator><![CDATA[Wenhan Wang]]></dc:creator>
            <pubDate>Fri, 02 Nov 2018 09:35:54 GMT</pubDate>
            <atom:updated>2018-11-02T09:36:55.799Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-6m5utoqfuihYDaA" /><figcaption>“man holding house plan paper” by <a href="https://unsplash.com/@rawpixel?utm_source=medium&amp;utm_medium=referral">rawpixel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>A small CRUD application</strong></p><p>So the first project that my team leader sent to me was to write a small backend application which can do some basic database operations like create, read, update, delete. Since I didn’t know anything about Node.js or server side development before(this is the first thing which came to my mind.) this thing gives me some pressure at first.</p><p><strong>Node.js</strong></p><p>Well, like what I said from the start, the first thought was “Node.js”. From my past experience, people always say Node.js is easy to learn for a front end developer. So the first article I read was <a href="https://www.sitepoint.com/node-js-is-the-new-black/">Node.js is the New Black — SitePoint</a> and I learned Node.js has a non-blocking event looping mechanism. But I don’t really know what will it impact a web application.</p><p>So that’s a todo for this weekend.</p><p>☐ Node.js Event Looping.</p><p>I guess for many front end developers who are new to this area. Will ask a question:</p><p><strong>Why Node.js?</strong></p><p>To be honest, I think the very first reason for me is <strong>easy to learn</strong>. For a developer, you entered the career with a must — learn new things everyday, especially for a front end developer. So in this scenario, we just need a small scale application to fulfill some basic functions. I found out Node.js is the perfect.</p><p>I’m not saying this is the only reason. This following links will explain why should we use Node.js.</p><p>[[<a href="https://medium.freecodecamp.org/what-exactly-is-node-js-ae36e97449f5">What exactly is Node.js? — freeCodeCamp.org</a>]]</p><p><em>Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.</em></p><p>[[<a href="https://youtu.be/8aGhZQkoFbQ">Philip Roberts: What the heck is the event loop anyway? | JSConf EU — YouTube</a>]]</p><p><strong>Express</strong></p><p><a href="https://medium.freecodecamp.org/going-out-to-eat-and-understanding-the-basics-of-express-js-f034a029fb66">Going out to eat and understanding the basics of Express.js</a></p><p>I just found out this article when I’m writing this post. Very good article to explain what Express really is.</p><p><strong>MongoDB+Mongoose</strong></p><p>Another big part is the database and then I chose MongoDB. I have some experience using firebase. So MongoDB is easy for me to pick up because the NoSQL mechanism. To access the data from MongoDB, I used mongoose in my design.</p><p><em>Mongoose provides a straight-forward, schema-based solution to model your application data. It includes built-in type casting, validation, query building, business logic hooks and more, out of the box.</em></p><p>This is what they wrote on their website.</p><p><strong>mLab</strong></p><p>There is one thing I found out interesting is almost every tutorial I read, they use mLab as the database example. mLab is a cloud based database system which is very easy to deploy and free of charge. If you just wanna write a small demo and no confidential data in the database, it would be a good choice.</p><p><strong>Articles</strong></p><p><a href="https://codeburst.io/writing-a-crud-app-with-node-js-and-mongodb-e0827cbbdafb">Writing a CRUD app with Node.js and MongoDB — codeburst</a></p><p>☐ <a href="https://medium.com/@bryantheastronaut/ok-here-we-go-b9f683c5a00c">MERN Stack — The Old Facebook Comment Box Tutorial except 2018</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea87f608cc73" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>