<?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: Rattanak Chea</title>
    <description>The latest articles on DEV Community by Rattanak Chea (@rattanakchea).</description>
    <link>https://dev.to/rattanakchea</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%2F35651%2Ff9ded142-017e-462b-bfe5-c7ef9335c3d2.jpeg</url>
      <title>DEV Community: Rattanak Chea</title>
      <link>https://dev.to/rattanakchea</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rattanakchea"/>
    <language>en</language>
    <item>
      <title>How do you balance between doing things right and doing things fast</title>
      <dc:creator>Rattanak Chea</dc:creator>
      <pubDate>Fri, 08 Nov 2019 06:23:34 +0000</pubDate>
      <link>https://dev.to/rattanakchea/how-do-you-balance-between-doing-things-right-and-doing-things-fast-4ba1</link>
      <guid>https://dev.to/rattanakchea/how-do-you-balance-between-doing-things-right-and-doing-things-fast-4ba1</guid>
      <description>&lt;p&gt;Often as a SWE, we have to meet deadlines and to deliver on time the code quality can decrease. Or worse, it is much harder to refactor bad code later.&lt;/p&gt;

&lt;p&gt;How do you balance between doing things right and doing things fast?&lt;/p&gt;

</description>
      <category>ask</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Podcast with caption generator?</title>
      <dc:creator>Rattanak Chea</dc:creator>
      <pubDate>Fri, 22 Feb 2019 04:50:30 +0000</pubDate>
      <link>https://dev.to/rattanakchea/podcast-with-caption-generator-4gp8</link>
      <guid>https://dev.to/rattanakchea/podcast-with-caption-generator-4gp8</guid>
      <description>&lt;p&gt;Hi,&lt;br&gt;
Do you guys know of any Podcast apps or service that could transcribe the talk?&lt;/p&gt;

&lt;p&gt;As a podcast listener, I want to go quickly read certain parts of the talk that I miss. But I don't want to listen to it over again.&lt;/p&gt;

</description>
      <category>podcast</category>
      <category>questions</category>
    </item>
    <item>
      <title>Algorithms for learning algorithms</title>
      <dc:creator>Rattanak Chea</dc:creator>
      <pubDate>Mon, 03 Dec 2018 22:02:58 +0000</pubDate>
      <link>https://dev.to/rattanakchea/algorithms-for-learning-algorithms-3lij</link>
      <guid>https://dev.to/rattanakchea/algorithms-for-learning-algorithms-3lij</guid>
      <description>&lt;h2&gt;
  
  
  Step 1: Learn the fundamental data structures and algorithms
&lt;/h2&gt;

&lt;p&gt;First, pick a favorite language to focus on and stick with it. Try to learn the core concepts of data structures because they are fundamentally almost the same from one language to another.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic data structures: Array, String, Boolean, LinkedList, Stack, Queue, 2-dimensional Array, Set, Binary Trees, etc.&lt;/li&gt;
&lt;li&gt;Conditional logic (&lt;code&gt;If&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Control flow statement (&lt;code&gt;for&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;, &lt;code&gt;do&lt;/code&gt; loops, etc...)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sorting&lt;/strong&gt; Algorithms: Insertion Sort, Bubble Sort, Selection Sort, Merge Sort, Quick Sort, Radix Sort. From here you will pick up different approaches Brute Force, Divide and Conquer&lt;/li&gt;
&lt;li&gt;Understanding &lt;strong&gt;Big O&lt;/strong&gt; Notation, runtime complexity, and space complexity help you write efficient algorithms.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Grasping these concepts are so important because they serve as the building blocks to understanding advanced concepts and solving complex problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here are a few relevant resources&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/fahimulhaq/top-8-data-structures-for-coding-interviews-and-practice-interview-questions-2pb"&gt;Top 8 Data Structures&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/saigowthamr/sorting-algorithms-beginners-guide-3ah4"&gt;Sorting Algorithms beginners guide&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Udemy's class: &lt;a href="https://www.udemy.com/js-algorithms-and-data-structures-masterclass/" rel="noopener noreferrer"&gt;JS Algorithms and Data Structures Masterclass&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Learn advanced concepts, data structures, and algorithms
&lt;/h2&gt;

&lt;p&gt;You may skip &lt;strong&gt;Step 1&lt;/strong&gt; if you are already familiar with most of the concepts and start learning more advanced topics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Heap, HashTable, Variations of Tree, Graph (DFS, BFS)&lt;/li&gt;
&lt;li&gt;Recursions&lt;/li&gt;
&lt;li&gt;Dynamic Programming&lt;/li&gt;
&lt;li&gt;Backtracking (for example, solving the N-Queen problem, sudoku)&lt;/li&gt;
&lt;li&gt;Bit Manipulation&lt;/li&gt;
&lt;li&gt;Object-oriented programming&lt;/li&gt;
&lt;li&gt;System design&lt;/li&gt;
&lt;li&gt;Medium to hard coding problems on Leetcode&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Free &lt;a href="https://github.com/donnemartin/system-design-primer" rel="noopener noreferrer"&gt;System Design Primer&lt;/a&gt; on Github&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/donnemartin/interactive-coding-challenges" rel="noopener noreferrer"&gt;Python's interactive coding challenges&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Udemy's &lt;a href="https://www.udemy.com/advanced-algorithms-in-java/" rel="noopener noreferrer"&gt;Advanced algorithm in Java&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1+2: Practice
&lt;/h2&gt;

&lt;p&gt;Practice makes perfect. While we are learning all the data structures and algorithms, it is important to do a lot of practicing in the meantime to reinforce what we learned.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;LeetCode is a free platform to practice coding&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mock Interview&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.pramp.com/" rel="noopener noreferrer"&gt;PRAMP&lt;/a&gt; is a great platform to practice mock interview. It is a two-way learning process for being both interviewer and interviewee.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I subscribe to &lt;a href="https://www.dailycodingproblem.com/" rel="noopener noreferrer"&gt;Daily Coding Problem&lt;/a&gt; to receive daily hand-picked coding problems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I subscribe to &lt;a href="https://www.interviewcake.com" rel="noopener noreferrer"&gt;Interview Cake&lt;/a&gt; to receive weekly coding problems. I find their explanation is detailed and easy to understand. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 3: Lots of reading + writing
&lt;/h2&gt;

&lt;p&gt;Reading a receptive skill from which we (inactively) learn from others' through their writing. We can gain a lot of knowledge by reading textbooks, blog articles, &lt;strong&gt;others' code&lt;/strong&gt;, readme files, etc.&lt;/p&gt;

&lt;p&gt;I occasionally write blog articles. Writing requires more time than reading as I need put some efforts into researching, formatting, spell checking, proofreading, etc. However, (I think) it forces me to use a different part of the brain and to be more articulative so that our readers could understand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Books&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cracking the coding interview&lt;/li&gt;
&lt;li&gt;Elements of Programming interviews&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Blog&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to"&gt;Dev.to&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Medium&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hashnode.com/" rel="noopener noreferrer"&gt;Hashnode&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 4: Contribute to open-source projects
&lt;/h2&gt;

&lt;p&gt;Find your favorite open-source project and make some contribution. It is a great way to learn using real-world projects. Dev has weekly open-source thread discussion.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Take a break
&lt;/h2&gt;

&lt;p&gt;Last but not least, don't forget to take a break from your connected computer and phone. Reward yourself for accomplishing a milestone you set out to do. Finally, I want to leave with a favorite quote below.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Enjoying the &lt;strong&gt;journey&lt;/strong&gt;, not just the &lt;strong&gt;destination&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Happy learning.&lt;/p&gt;

</description>
      <category>learning</category>
      <category>algorithms</category>
      <category>programming</category>
      <category>career</category>
    </item>
    <item>
      <title>10 Books I am reading (NOT at the same time)</title>
      <dc:creator>Rattanak Chea</dc:creator>
      <pubDate>Mon, 19 Nov 2018 23:00:31 +0000</pubDate>
      <link>https://dev.to/rattanakchea/10-books-i-am-reading-not-all-at-the-same-time-1j6a</link>
      <guid>https://dev.to/rattanakchea/10-books-i-am-reading-not-all-at-the-same-time-1j6a</guid>
      <description>&lt;p&gt;Inspired by Blaine Osepchuk's collection of books &lt;/p&gt;
&lt;div class="ltag__link"&gt;
  &lt;a href="/bosepchuk" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F21001%2F02beb73a-c476-4d04-a7d3-5564f4d6f85d.jpeg" alt="bosepchuk"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/bosepchuk/29-must-read-programming-books-2n45" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;29 Must Read Books For Programmers&lt;/h2&gt;
      &lt;h3&gt;Blaine Osepchuk ・ Nov 14 '18&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#career&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#productivity&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#learning&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#effectiveness&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;
, I'd like to share some books that I am currently reading.

&lt;p&gt;I tend to choose to buy a book very &lt;em&gt;carefully&lt;/em&gt; for two main reasons. One, a good book can be very expensive (I remember paying over $100 for a school textbook). Second,  it is time-consuming to finish a book and a commitment I don't want to give up.&lt;/p&gt;

&lt;p&gt;However, the joy of having a physical book nearby, from opening the Amazon box to touching and smelling the book for the first time is a great feeling and makes it worth an investment.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Cracking the Coding Interview&lt;/strong&gt; is a great book for sharping the coding skill and interview preparation. It has always been a Best-seller and recommended for, as the title suggests, &lt;strong&gt;cracking the  coding interview&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Elements of Programming Interviews&lt;/strong&gt; I recently bought this one as part of learning Python and preparing for job interviews. It has 300 interview questions covering a wide range of topics such as sorting, graph, dynamic programming, system designs, etc. I like the book organization. It is available in Python and Java. Must-read.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grokking Algorithms&lt;/strong&gt;. There are a lot of illustrations in the book which makes it fun to read. The author has a way of making a complex problem easy-to-understand.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Problem Solving with Algorithms and Data Structure with Python.&lt;/strong&gt; This is a solid book that covers all the basics on algorithms and data structures. It is good for quick reference and to build a strong foundation in CS. I believe without a strong foundation, a complex problem is even harder. There is free &lt;a href="http://interactivepython.org/runestone/static/pythonds/index.html" rel="noopener noreferrer"&gt;online version&lt;/a&gt; with interactive code playground.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Abstraction &amp;amp; Problem Solving with C++&lt;/strong&gt;. This is a book from during university. I have not read it for a while but it is there to remind me learning concepts and principles is transferable in software engineering.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Head First Design Patterns&lt;/strong&gt;. I have a love-hate relationship with Head First book series. You know when I am trying to read something serious, but there is a  cartoon. I think it is a great book because design patterns is a pretty challenging and important topic. Sometimes the best way to learn is not a hard way but an easy one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clean Architecture: A Craftsman's Guide to Software Structure and Design&lt;/strong&gt; by Robert C. Martin (Uncle Bob), the author of a very popular book &lt;strong&gt;Clean Code&lt;/strong&gt;. I have only read the first chapter of the book and learn about the complexity of software building. I am looking forward to reading it more.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Career Builiding&lt;/strong&gt; This is a book I picked from a library. It contains useful information on building a resume, interview process, workplace culture, burnout, etc. It is a good read to learn from the experiences of those who have been there.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Soft Skills, the software developer's life manual&lt;/strong&gt; Unlike many professions, a software developer has to spend a lot of time to keep learning and improving skills, mainly out of &lt;strong&gt;passion&lt;/strong&gt; and/or necessity. However, it can impacts other areas in life in a negative way such as dating, social life, and health issue. This books talks about how to deal with fitness and spiritual well-being, as well as how to balance your finance and market yourself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Quick Python Book&lt;/strong&gt;, provides a quick reference for python learner such as me.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you are still here, thank you for reading. What books are your favorites? What are you currently reading?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>learning</category>
      <category>career</category>
    </item>
    <item>
      <title>Markdown Cheatsheet for developers</title>
      <dc:creator>Rattanak Chea</dc:creator>
      <pubDate>Tue, 13 Nov 2018 18:16:33 +0000</pubDate>
      <link>https://dev.to/rattanakchea/markdown-cheatsheet-for-developers-2bjj</link>
      <guid>https://dev.to/rattanakchea/markdown-cheatsheet-for-developers-2bjj</guid>
      <description>&lt;p&gt;I prefer to use &lt;code&gt;Markdown&lt;/code&gt; for basically everything I can, from writing a personal blog, tech articles and even my resume. There are only a few syntaxes that I most commonly use. This post is intended for those who are new to &lt;code&gt;Markdown&lt;/code&gt; or need a refresh on its syntax. &lt;/p&gt;

&lt;h2&gt;
  
  
  Heading and List
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;#&lt;/code&gt; symbol is used for creating a heading. &lt;code&gt;#&lt;/code&gt; is for &lt;code&gt;H1&lt;/code&gt;. &lt;code&gt;##&lt;/code&gt; is for &lt;code&gt;H2&lt;/code&gt;. You can use up to 6 &lt;code&gt;#&lt;/code&gt; for &lt;code&gt;H6&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can make an unordered list with &lt;code&gt;-&lt;/code&gt; or &lt;code&gt;*&lt;/code&gt;.  To make an ordered list, use a a number. Below is an example of using heading and list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Why markdown? (H1)
##Reasons I like markdown (H2)
- Minimal, clean and less distraction for writing
- Good support for code blocks
- Can be exported to many formats including html, pdf, doc, latex, etc.
##My favorite markdown editors (H2)
1. Typora (Mac, Window)
2. Caret (Mac, Window)
3. Bear (Mac app store)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Why markdown?
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Reasons I like markdown
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Minimal, clean and less distracting for writing&lt;/li&gt;
&lt;li&gt;Good support for code blocks&lt;/li&gt;
&lt;li&gt;Can be exported to many formats including html, pdf, doc, latex, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  My favorite markdown editors
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Typora (Mac, Window)&lt;/li&gt;
&lt;li&gt;Caret (Mac, Window)&lt;/li&gt;
&lt;li&gt;Bear (Mac app store)&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Code Blocks
&lt;/h3&gt;

&lt;p&gt;You can call out code or a command within a sentence with single backticks. The text within the backticks will not be formatted. To format code or text into its own distinct block, use triple backticks.&lt;/p&gt;

&lt;pre&gt;

```
def foobaz():
    print("you can use ` for code snippet")
```


&lt;/pre&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def foobaz():
    print("you can use ` for code snippet")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Todo List
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- [ ] Write an article weekly 
- [ ] Repair windshield wipers of car 🚘
- [x] Publish **this** to dev.to
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;[ ] Write an article weekly &lt;/li&gt;
&lt;li&gt;[ ] Repair windshield wipers of car and add washer fluid 🚘&lt;/li&gt;
&lt;li&gt;[x] Publish &lt;strong&gt;this&lt;/strong&gt; to dev.to&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Styling
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**STRONG**
*emphasis*
~~strikethrough~~
Math $e=mc^2$ 
Use *** or - - - for horizontal rule
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;STRONG&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;emphasis&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;del&gt;strikethrough&lt;/del&gt;.&lt;/p&gt;

&lt;p&gt;Math $e=mc^2$ &lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Using Emoji&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Typing &lt;code&gt;:&lt;/code&gt; will bring up a list of suggested emojis, i.e &lt;code&gt;:EMOJICODE:&lt;/code&gt;. For a full list of emojis, check out &lt;a href="https://www.webpagefx.com/tools/emoji-cheat-sheet/" rel="noopener noreferrer"&gt;https://www.webpagefx.com/tools/emoji-cheat-sheet/&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`:unicorn:` :unicorn:
`:+1:`:+1:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;:unicorn:&lt;/code&gt; 🦄 (dev.to does not support emoji?)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;:+1:&lt;/code&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%2F261yfvmgm4khhv9epa9s.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%2F261yfvmgm4khhv9epa9s.png" alt="emoji" width="284" height="148"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Link and Image
&lt;/h3&gt;

&lt;p&gt;There are two ways to make links for text and images, inline and references.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inline Link&lt;/strong&gt;  &lt;code&gt;[link title](uri)&lt;/code&gt;. Inline link can be be absolute or relative URIs (link within local resources).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reference link&lt;/strong&gt; &lt;code&gt;[link][refereceID]&lt;/code&gt; is different from &lt;strong&gt;inline link&lt;/strong&gt; in that it is using a &lt;code&gt;[]&lt;/code&gt; for the second part instead of &lt;code&gt;()&lt;/code&gt;. Also, you need to add an &lt;code&gt;id&lt;/code&gt; reference later, so that markdown can link them together.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;[referenceID] : www.google.com "Google"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Image&lt;/strong&gt; is similar to inline and reference links, but there is an extra &lt;code&gt;!&lt;/code&gt; in in front.&lt;/p&gt;

&lt;p&gt;Syntanx &lt;code&gt;![Cat Image](catURI)&lt;/code&gt; or &lt;code&gt;![Dog Image][huskyDogID]&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Reference link to dev.to website](dev.to)

![image](https://i2.wp.com/fullstop360.com/blog/wp-content/uploads/2017/05/design-quotes-for-inspiration-2.jpg?)

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="//dev.to"&gt;Reference Link to dev.to website&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%2Fi2.wp.com%2Ffullstop360.com%2Fblog%2Fwp-content%2Fuploads%2F2017%2F05%2Fdesign-quotes-for-inspiration-2.jpg" 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%2Fi2.wp.com%2Ffullstop360.com%2Fblog%2Fwp-content%2Fuploads%2F2017%2F05%2Fdesign-quotes-for-inspiration-2.jpg" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Footnote References[^1]:

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

&lt;/div&gt;



&lt;p&gt;Footnote References&lt;sup id="fnref1"&gt;1&lt;/sup&gt;:&lt;/p&gt;

&lt;h3&gt;
  
  
  More
&lt;/h3&gt;

&lt;p&gt;You can Use [toc] to create Table of Content.&lt;/p&gt;

&lt;p&gt;Inline html and &lt;code&gt;&amp;lt;pre&amp;gt;&lt;/code&gt; tags &lt;code&gt;&amp;lt;span style="color: red"&amp;gt;Red Text&amp;lt;/span&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Red Text&lt;/span&gt; (should be red on fully supported Markdown editor)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quote&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;
&amp;gt;And so, my fellow Americans: ask not what your country can do for you — ask what you can do for your country&lt;/pre&gt;

&lt;blockquote&gt;
&lt;p&gt;And so, my fellow Americans: ask not what your country can do for you — ask what you can do for your country&lt;/p&gt;
&lt;/blockquote&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;&lt;a href="https://help.github.com/articles/basic-writing-and-formatting-syntax/" rel="noopener noreferrer"&gt;https://help.github.com/articles/basic-writing-and-formatting-syntax/&lt;/a&gt; "Github" ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>markdown</category>
      <category>cheatsheet</category>
    </item>
    <item>
      <title>Amazon's Interview Question: Count Island</title>
      <dc:creator>Rattanak Chea</dc:creator>
      <pubDate>Fri, 02 Nov 2018 16:05:43 +0000</pubDate>
      <link>https://dev.to/rattanakchea/amazons-interview-question-count-island-21h6</link>
      <guid>https://dev.to/rattanakchea/amazons-interview-question-count-island-21h6</guid>
      <description>&lt;p&gt;Last year when I was interviewing with Amazon, the first question that I was asked is to write a function &lt;code&gt;get_number_of_islands(matrix)&lt;/code&gt; . This was the first time I had seen this problem. It was hard for me. In retrospect, I want to share what I had learned and approaches to solving this problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;Given a 2 dimension array &lt;code&gt;matrix&lt;/code&gt;  of &lt;code&gt;0s&lt;/code&gt; and &lt;code&gt;1s&lt;/code&gt;, count the number of islands of &lt;code&gt;1s&lt;/code&gt;. An island is surrounded by a group of adjacent cells that are all &lt;code&gt;1s&lt;/code&gt;. A cell can only be adjacent to each other horizontally and vertically.&lt;/p&gt;

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



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="n"&gt;binaryMatrix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&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="mi"&gt;1&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="mi"&gt;1&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="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="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                         &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&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="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="mi"&gt;1&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="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="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="mi"&gt;1&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="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                         &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&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="mi"&gt;1&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="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;  &lt;span class="c1"&gt;# there are six islands
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Approaches
&lt;/h2&gt;

&lt;p&gt;First, you should ask the interviewer questions for clarification, paraphrase the problem to make sure you understand it correctly, and/or state any assumptions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does the matrix have the same number of columns or rows? (Interviewer: it should not matter)&lt;/li&gt;
&lt;li&gt;We assume that the cell can be adjacent only horizontally and vertically, &lt;strong&gt;not diagonally&lt;/strong&gt;? (Correct)&lt;/li&gt;
&lt;li&gt;The function should handle the empty matrix and out of bound data access correctly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Second, now you can talk about the processes to solve this problem out &lt;strong&gt;loud&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Okay, so we want to &lt;em&gt;iterate over each cell&lt;/em&gt; in the matrix. Then we can check if the cell is &lt;code&gt;1&lt;/code&gt; or &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It is a &lt;code&gt;0&lt;/code&gt;, it is not an island and we can continue. If it is a &lt;code&gt;1&lt;/code&gt;, it is guaranteed that we found &lt;strong&gt;1&lt;/strong&gt; island. (sound like a base case? ) At this point, we need a mechanism to make this cell as &lt;strong&gt;visited&lt;/strong&gt;, so next time around we can skip it to avoid repeated counting. After that, we want to look at all the &lt;strong&gt;adjacent&lt;/strong&gt; cells to repeat the process (recursion).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pseudocode&lt;/strong&gt;&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;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;visited&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="c1"&gt;# array to keep track of visited cell
&lt;/span&gt;    &lt;span class="n"&gt;num_islands&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="c1"&gt;# start with zero
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;matrix&lt;/span&gt;
          &lt;span class="n"&gt;num_island&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nf"&gt;get_number_of_islands&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;matrix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;#return 1 if it is an island
&lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;num_island&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_number_of_islands&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;matrix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;visited&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;check&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="n"&gt;bound&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;matrix&lt;/span&gt;
    &lt;span class="n"&gt;check&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;we&lt;/span&gt; &lt;span class="n"&gt;already&lt;/span&gt; &lt;span class="n"&gt;visited&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;cell&lt;/span&gt; &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt;
    &lt;span class="n"&gt;check&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;cell&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

    &lt;span class="n"&gt;mark&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;cell&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;visited&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;visited&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;
    &lt;span class="n"&gt;recursive&lt;/span&gt; &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="nf"&gt;get_number_of_islands&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="n"&gt;adjacent&lt;/span&gt; &lt;span class="n"&gt;cell&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Solution (Python)
&lt;/h2&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;get_number_of_islands&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binaryMatrix&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;rows&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;binaryMatrix&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;cols&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;binaryMatrix&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="c1"&gt;# you can use Set if you like
&lt;/span&gt;    &lt;span class="c1"&gt;# or change the content of binaryMatrix as it is visited
&lt;/span&gt;    &lt;span class="n"&gt;visited&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&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;col&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;cols&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;r&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;rows&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="n"&gt;number_of_island&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;row&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;rows&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;col&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;cols&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;number_of_island&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nf"&gt;get_island&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binaryMatrix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;visited&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;number_of_island&lt;/span&gt;


&lt;span class="c1"&gt;# get a continuous island
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_island&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binaryMatrix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;visited&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nf"&gt;is_valid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binaryMatrix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;visited&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;col&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="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;binaryMatrix&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

    &lt;span class="c1"&gt;# mark as visited
&lt;/span&gt;    &lt;span class="n"&gt;visited&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;col&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="nf"&gt;get_island&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binaryMatrix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;col&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="n"&gt;visited&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;get_island&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binaryMatrix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;col&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="n"&gt;visited&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;get_island&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binaryMatrix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&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="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;visited&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;get_island&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binaryMatrix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&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="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;visited&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;is_valid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binaryMatrix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;rows&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;binaryMatrix&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;cols&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;binaryMatrix&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="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;cols&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Extra
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What is the time and space complexities?&lt;/li&gt;
&lt;li&gt;Question variation: Find the island with the largest size? In this case above, return &lt;code&gt;5&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;This problem can also be solved without using recursion as well. But it is required a Queue or Stack to keep track of adjacent cells to visit. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Notes
&lt;/h2&gt;

&lt;p&gt;This question can be hard and make an interviewee being stuck (including myself) due to a number of reasons.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;unfamiliarity with basic &lt;strong&gt;Graph&lt;/strong&gt; data structure and the concepts of &lt;strong&gt;DFS&lt;/strong&gt; or &lt;strong&gt;BFS&lt;/strong&gt; traversal. This is considered a graph with the adjacency matrix.&lt;/li&gt;
&lt;li&gt;being stuck in handling the base case and recursive case.&lt;/li&gt;
&lt;li&gt;interview time constraint&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*Cover image is obtained from unsplash.com&lt;/p&gt;

</description>
      <category>interview</category>
      <category>code</category>
      <category>graph</category>
      <category>recursion</category>
    </item>
    <item>
      <title>Python tips 101</title>
      <dc:creator>Rattanak Chea</dc:creator>
      <pubDate>Fri, 26 Oct 2018 21:51:29 +0000</pubDate>
      <link>https://dev.to/rattanakchea/python-tips-101-bbd</link>
      <guid>https://dev.to/rattanakchea/python-tips-101-bbd</guid>
      <description>&lt;p&gt;I have background with mostly JavaScript and a strong type language such as Java.&lt;br&gt;
Because Python's popularity in Machine learning, AI, data science, as well as backend web development, I decided to really learn it. I have observed that it has very elegant, and clean syntax which enforces us to think of the code on a high level (not too worried about the little detail) and to format code nicely with its strict indentation rule.&lt;/p&gt;

&lt;p&gt;Below is some Python and JavaScript's code snippets to illustrate some common usages and language comparison.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;I hope to write more advanced Python topics (I need to learn them first :-p) in future post:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[] generators&lt;/li&gt;
&lt;li&gt;[] iterators&lt;/li&gt;
&lt;li&gt;[] decorators&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have any comments and tips, please write below.&lt;/p&gt;

&lt;p&gt;For side-by-side code comparison: &lt;a href="https://leetcode.com/playground/vDy2x7Co/shared"&gt;https://leetcode.com/playground/vDy2x7Co/shared&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>How do you rate your (a programming language) skill on a scale of 1 to 10?</title>
      <dc:creator>Rattanak Chea</dc:creator>
      <pubDate>Thu, 30 Aug 2018 00:13:49 +0000</pubDate>
      <link>https://dev.to/rattanakchea/how-do-you-rate-your-a-programming-language-skill-on-a-scale-of-1-to-10-34ka</link>
      <guid>https://dev.to/rattanakchea/how-do-you-rate-your-a-programming-language-skill-on-a-scale-of-1-to-10-34ka</guid>
      <description>&lt;p&gt;&lt;strong&gt;How do you rate your javaScript skill? Give a number form 1-10.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Have you been asked this question in a screening interview or in-person interview?&lt;/p&gt;

&lt;p&gt;For me, I don't really know how to answer this question. But I know that 9 or 10 might not be the best answer unless you know the language inside out. But I know that I have overcome some hurdles of becoming a better developer over the last few years. I find myself interested in learning how a library was built and building one myself, and digging deep into its code base.&lt;/p&gt;

&lt;p&gt;How do you answer this question? Can you share your experience or your reflection of where you are?&lt;br&gt;
What is the journey like for a person to become really good? For example, a creator of React, Redux, or Rails framework?&lt;/p&gt;

</description>
      <category>interview</category>
      <category>javascript</category>
      <category>reflection</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Learn Dynamic Programming using Fibonacci as an example</title>
      <dc:creator>Rattanak Chea</dc:creator>
      <pubDate>Fri, 20 Jul 2018 00:52:17 +0000</pubDate>
      <link>https://dev.to/rattanakchea/dynamic-programming-in-plain-english-using-fibonacci-as-an-example-37m1</link>
      <guid>https://dev.to/rattanakchea/dynamic-programming-in-plain-english-using-fibonacci-as-an-example-37m1</guid>
      <description>&lt;p&gt;To be honest, &lt;strong&gt;Dynamic Programming&lt;/strong&gt; (DP) is a topic that is hard for me to wrap my head around. I think one of the reason is that I was not learning it the right way and understand its concept strong enough to build a mental model of how to solve it properly. Often time, either it takes me a very long time to solve a DP problem and forget about it in the next day, or I just can't.&lt;/p&gt;

&lt;p&gt;Learning how to learn is important for me to retain as much as possible. And I think that a fibonacci sequence is a great example of learning DP. I will show you 4 different ways to solve it: Recursive, DP using recursive, DP Bottom Up Approach (optimized runtime), DP Bottom Up Approach (optimized space).&lt;/p&gt;

&lt;h2&gt;
  
  
  Statement
&lt;/h2&gt;

&lt;p&gt;Find the index value, given a number n in  the Fibonacci sequence&lt;br&gt;
&lt;code&gt;1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ....&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A Fibonacci is a sequence of number where the current number is the result of the sum of the previous two numbers. For example, fib(5) should return 5.&lt;/p&gt;
&lt;h1&gt;
  
  
  Solutions
&lt;/h1&gt;
&lt;h2&gt;
  
  
  1. using Recursion
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;fibRecursive&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&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;n&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;=&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;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;fibRecursive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&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="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;fibRecursive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This implementation is concise and easy to understand.&lt;br&gt;
We just need have base case when &lt;code&gt;n &amp;lt;=2&lt;/code&gt; and do recursive calls on &lt;code&gt;n-1&lt;/code&gt; &amp;amp; &lt;code&gt;n-2&lt;/code&gt;.&lt;br&gt;
The drawback is 1 call becomes 2 calls. 2 calls becomes 4. etc. It is exponential.&lt;br&gt;
Time complexity O(2^n) and space complexity is also O(2^n) for all stack calls.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. DP = recursion + memoziation
&lt;/h2&gt;

&lt;p&gt;In a nutshell, DP is a efficient way in which we can use memoziation to cache visited data to faster retrieval later on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;mem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;fibRecursiveMem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&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;mem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;mem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;n&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;n&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;mem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;n&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="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;mem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fibRecursiveMem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&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="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;fibRecursiveMem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&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="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;mem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;n&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;This implementation makes use of &lt;code&gt;mem&lt;/code&gt; as an array (or hash) to store value of an already computed num. This will greatly reduce the number of call stack and duplicated computation in the call stack.&lt;br&gt;
For example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fib(4) = fib(3) + fib(2)
fib(2), fib(3) were already saved into mem, so will fib(4)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fib(5) = fib(4) + fib(3)
The previously saved fib(3) and fib(4) will be used to avoid duplicated calculation and call stacks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Time complexity O(N), Space O(N)&lt;/p&gt;

&lt;h2&gt;
  
  
  3. DP Bottom Up approach (Optimized runtime)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;fibBottomUp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&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="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;mem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&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;i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;mem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&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;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;mem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&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="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;mem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&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="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;mem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&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="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;mem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;n&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;We can further optimize the runtime by using a bottom up solution with a &lt;code&gt;for&lt;/code&gt; or &lt;code&gt;while&lt;/code&gt; loop. We still use memoization but we no longer have recursive calls.&lt;br&gt;
Time Complexity O(n), space O(n)&lt;/p&gt;

&lt;h2&gt;
  
  
  3. DP Bottom Up approach (Optimized space)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;fibBottomUp2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&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="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;first&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;second&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&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="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&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;i&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="nx"&gt;second&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="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;temp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;second&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nx"&gt;second&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;first&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;second&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nx"&gt;first&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;temp&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;second&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;As you can see, we only need the last two number to calculate the next Fibonacci sequence. With this logic in mind, we can use two variable to store the last two Fibonacci sequence.&lt;br&gt;
Time O(N), Space O(1)&lt;/p&gt;

&lt;p&gt;Leave the comments below for more discussions and useful resources.&lt;/p&gt;

&lt;p&gt;Further reading:&lt;br&gt;
Source code:&lt;br&gt;
&lt;a href="https://github.com/rattanakchea/coding_interview/blob/master/src/fibonacii.js"&gt;https://github.com/rattanakchea/coding_interview/blob/master/src/fibonacii.js&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This blog post include a test case and run time performance&lt;br&gt;
&lt;a href="https://medium.com/developers-writing/fibonacci-sequence-algorithm-in-javascript-b253dc7e320e"&gt;https://medium.com/developers-writing/fibonacci-sequence-algorithm-in-javascript-b253dc7e320e&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dp</category>
      <category>fibonacci</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>How I built my site v3.0 in 24 hours (non-continuously)</title>
      <dc:creator>Rattanak Chea</dc:creator>
      <pubDate>Mon, 27 Nov 2017 06:41:16 +0000</pubDate>
      <link>https://dev.to/rattanakchea/how-i-built-my-site-v30-in-24-hours-non-continuously-2od</link>
      <guid>https://dev.to/rattanakchea/how-i-built-my-site-v30-in-24-hours-non-continuously-2od</guid>
      <description>&lt;h2&gt;
  
  
  Goals
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Build a &lt;em&gt;minimalist, maintainable, and FREE&lt;/em&gt; website &lt;em&gt;quickly&lt;/em&gt; to showcase my work.&lt;/li&gt;
&lt;li&gt;Make use of new technology where appropriate.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Building my new website was actually more challenging and took me longer than I anticipated. To keep it short, let me jump straight to the &lt;strong&gt;challenges&lt;/strong&gt; when working on it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Which framework should I choose? Or should I use none?&lt;/strong&gt;&lt;br&gt;
I have looked into the options of &lt;strong&gt;React, Angular 4.0, and Yeoman web app generator&lt;/strong&gt; for JavaScript library and &lt;strong&gt;Bulma, Boostrap, Material&lt;/strong&gt; for a CSS framework. It was a difficult decision because there were so many choices. On one hand, I want to learn something new. On the other hand, choosing a new technology stack will not only slow down my development, but also make the project much more difficult to manage, especially when working in a one-man team. Working on UI, the application logic, and learning about new technology at the same time is difficult, counter-production and can be frustrating. After back and forth tests and trials, I chose Angular 4.0 + Bootstrap mainly because I have some experience with these two more than the others and I was happy with development speed. Personal satisfaction equals increased productivity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.  How to get a functional website up in as little time as possible without a UI prototype?&lt;/strong&gt;&lt;br&gt;
I wanted to get my new site up in as little time as possible. I did not have enough time and photoshop/sketch skills to polish a clean UI with color themes, beautiful fonts, etc, nor I wanted to spend time on it. I only drew a simple quick wireframe on a paper for UI mockup. I reused some of most common UI components I could find on Bootstrap so that I could focus on some of my design ideas and the application logic. It was challenging to work on development without solid prototype in mind. However, I was happy with final outcome that I can iterate on in future version.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. How to make the site maintainable, and the cost is still FREE?&lt;/strong&gt;&lt;br&gt;
I think one of the most important aspects of any websites/applications is that it is maintainable. It means that the code is organized and easy to understand. It requires few steps to update and deploy a new version. When the project is self-explanatory, and requires minimal time to understand, it will be more maintainable and surviving in many more years. In this project, I have to do two steps (can be combined to one) &lt;code&gt;npm run pre-deploy&lt;/code&gt;,  then &lt;code&gt;npm run deploy&lt;/code&gt; to deploy the site to Github page which is free to host static sites. &lt;/p&gt;

&lt;p&gt;Check out my current and previous websites below. Which one you like better? Leave comments and feedbacks; i love to hear.&lt;/p&gt;

&lt;h3&gt;
  
  
  Nov 2017 &lt;a href="https://rattanakchea.github.io"&gt;rattanakchea.github.io&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZuhxTRK2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/rattanakchea/rattanakchea.github.io/dev/src/assets/portfolio2017.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZuhxTRK2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/rattanakchea/rattanakchea.github.io/dev/src/assets/portfolio2017.png" alt="porfolio 2017"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XERh3okF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/rattanakchea/rattanakchea.github.io/dev/src/assets/portfolio2017-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XERh3okF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/rattanakchea/rattanakchea.github.io/dev/src/assets/portfolio2017-2.png" alt="porfolio 2017-work"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2016
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y9ti7wNO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/rattanakchea/rattanakchea.github.io/dev/src/assets/portfolio2016.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y9ti7wNO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/rattanakchea/rattanakchea.github.io/dev/src/assets/portfolio2016.png" alt="porfolio 2016"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2014
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EpqMh0xl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/rattanakchea/rattanakchea.github.io/dev/src/assets/portfolio2014.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EpqMh0xl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/rattanakchea/rattanakchea.github.io/dev/src/assets/portfolio2014.png" alt="porfolio 2014"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>design</category>
      <category>portfolio</category>
      <category>dev</category>
    </item>
    <item>
      <title>Awesome resources for learning to code</title>
      <dc:creator>Rattanak Chea</dc:creator>
      <pubDate>Sat, 21 Oct 2017 09:42:10 +0000</pubDate>
      <link>https://dev.to/rattanakchea/awesome-resources-for-learning-to-code-66i</link>
      <guid>https://dev.to/rattanakchea/awesome-resources-for-learning-to-code-66i</guid>
      <description>&lt;p&gt;Some people learn best by reading textbooks. While others prefer watching video tutorials, or reading tech blogs. Others just learn by working on real world projects. There is no one size fit all. The list below is subjective.&lt;/p&gt;

&lt;h2&gt;
  
  
  Coding
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Leetcode.
This is my favorite coding site because it contains a variety of challenging questions and algorithms. Plus, it supports many programming languages.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.interviewcake.com/"&gt;InterviewCake&lt;/a&gt;.
I subscribed InterviewCake site and got a free weekly challenge question. It is a great way to set a reminder to practice and improve coding skills.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Video tutorials
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Pluralsight&lt;/li&gt;
&lt;li&gt;Lynda&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pluralsight and Lynda are great for learners both students and professionals of all levels. These two paid subscription services have a vast collection of video tutorials for many fields of study. However, because technology is changing rapidly, some contents are out of date. And you also want to be little picky when choosing an instructor and a course to invest your time with.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://egghead.io/"&gt;Egghead&lt;/a&gt;. contains short, instructional video tutorials. It seems to target specific tasks suitable for on the job applications.&lt;/li&gt;
&lt;li&gt;Scotch.io&lt;/li&gt;
&lt;li&gt;Tutsplus.com&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Blogs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Dev.to
What I likes most about dev.to is an engaging community, great in-depth topics and real work experience shared by the community.&lt;/li&gt;
&lt;li&gt;Medium.com
It is quite often that a Google search of a particular topic lands me on Medium site. It goes to say that it has a great number of contributors and writers for many practical topics and hand-on tutorials.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Textbooks
&lt;/h2&gt;

&lt;p&gt;If you are a fan of reading textbooks from well known authors. Here a few I like.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;O’reilly publication. I started out my web developer career by reading a few books from O’reilly. I think they are worth the read.&lt;/li&gt;
&lt;li&gt;Manning publication. I like their books and writing approaches to each topic.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Learn by specific topic
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Stackoverflow. An indispensable tool for Q&amp;amp;A&lt;/li&gt;
&lt;li&gt;If you want to learn specific topic such as Node.js, PHP, or Rails, there are websites dedicated to those domains, (e.g. Laracasts for PHP)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is by no mean a complete list of available resources on the web. I did not intend this post to be a review of the resources. Therefore, I keep each bullet as short as possible. If you are reading this, you have probably heard of most of the sites listed above, if not all. Please comment below if you know a good one. As a lifelong learner, I am always excited to explore and learn.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>learning</category>
    </item>
    <item>
      <title>Coding Interview Q&amp;A Project</title>
      <dc:creator>Rattanak Chea</dc:creator>
      <pubDate>Sun, 08 Oct 2017 01:29:10 +0000</pubDate>
      <link>https://dev.to/rattanakchea/coding-interview-questions-7k9</link>
      <guid>https://dev.to/rattanakchea/coding-interview-questions-7k9</guid>
      <description>&lt;p&gt;One of my biggest challenges of doing a successful whiteboard coding interview is that I don't practice writing algorithms that are asked during interview (For example, reversing a LinkedList, checking if Binary Tree is balanced, etc..) on my day-to-day tasks. Just like other skills, if we are not practicing, they will get rusty.&lt;/p&gt;

&lt;p&gt;Over the past several years, I have had several coding interviews. After each interview, regardless of the outcome, I wrote down the interview questions and practiced them again when I got a chance.&lt;/p&gt;

&lt;p&gt;Therefore I made an open source Test-Driven project, &lt;a href="https://github.com/rattanakchea/coding_interview" rel="noopener noreferrer"&gt;Coding_Interview&lt;/a&gt; that is collection of common questions asked in interview. So far, I have some questions, answers, tests written in JavaScript, Python, and Java. This is on going project. More questions and answers are being added.&lt;/p&gt;

&lt;p&gt;Some example questions include&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How do find common numbers between two arrays of numbers?&lt;/li&gt;
&lt;li&gt;Write a function to capitalize each word in a sentence except &lt;em&gt;a, the, to, at, in, with, and but, or&lt;/em&gt; ?&lt;/li&gt;
&lt;li&gt;Write a function to check if a string is unique? (i.e no duplicate character)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Frattanakchea%2Fcoding_interview%2Fmaster%2Fscreenshot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Frattanakchea%2Fcoding_interview%2Fmaster%2Fscreenshot.png" alt="project screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Code written in JavaScript, Python, Java&lt;/li&gt;
&lt;li&gt;Testing with Mocha library, Unit Test for Python&lt;/li&gt;
&lt;li&gt;Each question is accompanied by instruction and example&lt;/li&gt;
&lt;li&gt;Organized and reusable code&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to run
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Clone the repo, then &lt;code&gt;npm install&lt;/code&gt; all dependencies&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;npm run test&lt;/code&gt; to run all test cases for JavaScript&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;npm run test-p&lt;/code&gt; to run Python test cases&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How can you help
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you just want read more about it, please go to: &lt;a href="https://github.com/rattanakchea/coding_interview" rel="noopener noreferrer"&gt;Coding_Interview&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;If you would like to contribute, please submit a PR. I appreciate.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>coding</category>
      <category>interview</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
