<?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: Danny</title>
    <description>The latest articles on DEV Community by Danny (@wozaisuzhou).</description>
    <link>https://dev.to/wozaisuzhou</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%2F466528%2F453a34c9-1b6f-4494-aac9-db6fa09a130a.png</url>
      <title>DEV Community: Danny</title>
      <link>https://dev.to/wozaisuzhou</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wozaisuzhou"/>
    <language>en</language>
    <item>
      <title>Algorithms Challenge (2) Combination Coin Change - Different coins added up to a given amount</title>
      <dc:creator>Danny</dc:creator>
      <pubDate>Mon, 19 Sep 2022 01:29:22 +0000</pubDate>
      <link>https://dev.to/wozaisuzhou/algorithms-challenge-2-combination-coin-change-different-coins-added-up-to-a-given-amount-2icd</link>
      <guid>https://dev.to/wozaisuzhou/algorithms-challenge-2-combination-coin-change-different-coins-added-up-to-a-given-amount-2icd</guid>
      <description>&lt;p&gt;Question : &lt;br&gt;
There are {1, 2 , 5} dollar types coins for selection. Use different combinations of these types coins to adding up to the given amount 50. &lt;/p&gt;

&lt;p&gt;Answer:&lt;br&gt;
We can use different types of dynamic programming methods to solve this problem.  In this article , we choose to use Dynamic programming -  Bottom up method. &lt;/p&gt;

&lt;p&gt;The implementation logic is simple like this : &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set combinations as an array , its size is "amount +1" &lt;/li&gt;
&lt;li&gt;combinations[0] = 1 ,  it means the first combination ways number is 1 &lt;/li&gt;
&lt;li&gt;We can loop the coins into the combinations array. When 
the amount(the value in the position of the combinations array) is greater than coin , then we can use the formular : 
combinations[amount] += combinations[amount - coin];&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Code: &lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

public class coinsCombinationWays {

    static int getTotalWays(int[] coins, int amount){
         int[] combinations = new int[amount + 1];
         combinations[0] = 1;

         for(int coin: coins) {
            for(int j=1; j&amp;lt;combinations.length; j++){
              if(j&amp;gt;=coin)
               combinations[j] += combinations[j-coin];
           }
         }
        return combinations[amount];
   } 

   public static void main(String[] args) {
       int[] coins = {1, 2, 5};
       int amount= 50; 

       int totalWays += getTotalWays(coins, amount);
       System.out.println(totalWays);
    }

}

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

&lt;/div&gt;

</description>
      <category>java</category>
      <category>algorithms</category>
      <category>dynamicprogramming</category>
      <category>bottonup</category>
    </item>
    <item>
      <title>Algorithms Challenge (1) How to print out Fibonacci series in two lines code</title>
      <dc:creator>Danny</dc:creator>
      <pubDate>Fri, 16 Sep 2022 20:26:00 +0000</pubDate>
      <link>https://dev.to/wozaisuzhou/algorithms-challenge-1-how-to-print-out-fibonacci-series-in-two-lines-code-16dl</link>
      <guid>https://dev.to/wozaisuzhou/algorithms-challenge-1-how-to-print-out-fibonacci-series-in-two-lines-code-16dl</guid>
      <description>&lt;p&gt;Print out Fibonacci numbers in range 0 - 100 &lt;/p&gt;

&lt;p&gt;Concept :  print out two numbers every time&lt;/p&gt;

&lt;p&gt;Code in java:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class fibonacci {
   public static void main(String[] args) {
         for(int a = 0, b=1; a &amp;lt; 100 ; a+=b, b+=a)
             System.out.println(a + "," + (b&amp;lt;100 ? b + ",": ""));
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result : &lt;br&gt;
0,1,&lt;br&gt;
1,2,&lt;br&gt;
3,5,&lt;br&gt;
8,13,&lt;br&gt;
21,34,&lt;br&gt;
55,89,&lt;/p&gt;

</description>
      <category>fibonacci</category>
      <category>java</category>
      <category>algorithms</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
