<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>JSAlgorithm</title>
	<atom:link href="https://jsalgorithm.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://jsalgorithm.com</link>
	<description></description>
	<lastBuildDate>Thu, 04 Jun 2020 01:11:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.5.15</generator>
<site xmlns="com-wordpress:feed-additions:1">177240629</site>	<item>
		<title>Spiral Matrix</title>
		<link>https://jsalgorithm.com/2020/06/04/spiral-matrix/</link>
					<comments>https://jsalgorithm.com/2020/06/04/spiral-matrix/#respond</comments>
		
		<dc:creator><![CDATA[Ronald]]></dc:creator>
		<pubDate>Thu, 04 Jun 2020 01:11:55 +0000</pubDate>
				<category><![CDATA[Array]]></category>
		<category><![CDATA[Loop]]></category>
		<category><![CDATA[Matrix]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[matrix]]></category>
		<guid isPermaLink="false">http://50.19.13.106/?p=140</guid>

					<description><![CDATA[function spiralMatrix(dimension) { let matrix = []; // create blank matrix based from given dimension for (let i = 0; i &#60; dimension; i++) { matrix.push(new Array(dimension).fill(0)) } let counter = 1; let startRow = 0, endRow = dimension, startColumn = 0, endColumn = dimension; while (startRow &#60; endRow &#38;&#38; startColumn &#60; endColumn) { // [&#8230;]]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-preformatted">function spiralMatrix(dimension) {

    let matrix = [];
    // create blank matrix based from given dimension
    for (let i = 0; i &lt; dimension; i++) {
        matrix.push(new <strong><em>Array</em></strong>(dimension).fill(0))
    }

    let counter = 1;
    let startRow = 0, endRow = dimension, startColumn = 0, endColumn = dimension;


    while (startRow &lt; endRow &amp;&amp; startColumn &lt; endColumn) {

        // top left -> top right
        for (let i = startColumn; i &lt; endColumn; i++) {
            matrix[startRow][i] = counter++;
        }
        startRow++

        // top right -> bottom right
        for (let i = startRow; i &lt; endRow; i++) {
            matrix[i][endColumn - 1] = counter++;
        }
        endColumn--;

        // bottom right -> bottom left
        for (let i = endColumn - 1; i >= startColumn; i--) {
            matrix[endRow - 1][i] = counter++;
        }
        endRow--;


        // bottom left -> top left
        for (let i = endRow; i > startRow; i--) {
            matrix[i - 1][startColumn] = counter++;
        }
        startColumn++;

    }

     return matrix;
}</pre>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://jsalgorithm.com/2020/06/04/spiral-matrix/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">140</post-id>	</item>
		<item>
		<title>Algorithms in JavaScript &#8211; Full Course for Beginners</title>
		<link>https://jsalgorithm.com/2020/05/21/algorithms-in-javascript-full-course-for-beginners/</link>
					<comments>https://jsalgorithm.com/2020/05/21/algorithms-in-javascript-full-course-for-beginners/#respond</comments>
		
		<dc:creator><![CDATA[Ronald]]></dc:creator>
		<pubDate>Thu, 21 May 2020 12:04:32 +0000</pubDate>
				<category><![CDATA[Youtube]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[data-structure]]></category>
		<category><![CDATA[youtube]]></category>
		<guid isPermaLink="false">http://50.19.13.106/?p=135</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
httpss://www.youtube.com/watch?v=t2CEgPsws3U
</div></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://jsalgorithm.com/2020/05/21/algorithms-in-javascript-full-course-for-beginners/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">135</post-id>	</item>
		<item>
		<title>Game Of Life (Optimized)</title>
		<link>https://jsalgorithm.com/2020/05/21/game-of-life-optimized/</link>
					<comments>https://jsalgorithm.com/2020/05/21/game-of-life-optimized/#respond</comments>
		
		<dc:creator><![CDATA[Ronald]]></dc:creator>
		<pubDate>Thu, 21 May 2020 02:46:57 +0000</pubDate>
				<category><![CDATA[Array]]></category>
		<category><![CDATA[Loop]]></category>
		<category><![CDATA[Matrix]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[bitshift]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[matrix]]></category>
		<guid isPermaLink="false">http://50.19.13.106/?p=132</guid>

					<description><![CDATA[let gameOfLife = function(board) { if (!board) return []; let LIVE = 1, DEAD = 0, ALIVE_TO_DEAD = 0b01, // [next state, current state] ALIVE_TO_ALIVE = 0b11, DEAD_TO_ALIVE = 0b10, DEAD_TO_DEAD = 0b00, maxRow = board.length - 1, maxCol = board[0].length - 1; function getAdjacentCount(row, col, valueToCompare) { let sum = 0; for (let i [&#8230;]]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-preformatted">let gameOfLife = function(board) {

    if (!board) return [];

    let LIVE = 1,
        DEAD = 0,
        ALIVE_TO_DEAD = 0b01, // [next state, current state]
        ALIVE_TO_ALIVE = 0b11,
        DEAD_TO_ALIVE = 0b10,
        DEAD_TO_DEAD = 0b00,
        maxRow = board.length - 1,
        maxCol = board[0].length - 1;

    function getAdjacentCount(row, col, valueToCompare) {
        let sum = 0;
        for (let i = <strong><em>Math</em></strong>.max(row - 1, 0); i &lt;= <strong><em>Math</em></strong>.min(row + 1, maxRow); i++) {
            for (let j = <strong><em>Math</em></strong>.max(col - 1, 0); j &lt;= <strong><em>Math</em></strong>.min(col + 1, maxCol); j++) {
                if (i === row &amp;&amp; j === col) continue;
                if (board[i][j] &amp; 1 === valueToCompare) sum = sum + 1;
            }
        }
        return sum;
    }

    function getNextValue(row, col) {
        const val = board[row][col];
        let liveNeighbors = getAdjacentCount(row, col, LIVE);
        if (val === LIVE) {

            // Any live cell with fewer than two live neighbors dies, as if caused by under-population.
            // Any live cell with more than three live neighbors dies, as if by over-population..
            if (liveNeighbors &lt; 2 || liveNeighbors > 3) {
                return ALIVE_TO_DEAD;
            }
            // Any live cell with two or three live neighbors lives on to the next generation.
            return ALIVE_TO_ALIVE;
        }
        // cell is DEAD
        else {
            // Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.
            if (liveNeighbors === 3) {
                return DEAD_TO_ALIVE;
            }
            // no condition
            return DEAD_TO_DEAD;
        }
    }

    for (let row = 0; row &lt;= maxRow; row++) {
        for (let col = 0; col &lt;= maxCol;col++) {
            board[row][col] = getNextValue(row, col);
        }
    }

    for (let row = 0; row &lt;= maxRow; row++) {
        for (let col = 0; col &lt;= maxCol;col++) {
            board[row][col] = board[row][col] >> 1;
        }
    }

};</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://jsalgorithm.com/2020/05/21/game-of-life-optimized/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">132</post-id>	</item>
		<item>
		<title>Game Of Life</title>
		<link>https://jsalgorithm.com/2020/05/21/game-of-life/</link>
					<comments>https://jsalgorithm.com/2020/05/21/game-of-life/#respond</comments>
		
		<dc:creator><![CDATA[Ronald]]></dc:creator>
		<pubDate>Thu, 21 May 2020 02:11:49 +0000</pubDate>
				<category><![CDATA[Array]]></category>
		<category><![CDATA[Loop]]></category>
		<category><![CDATA[Matrix]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[matrix]]></category>
		<guid isPermaLink="false">http://50.19.13.106/?p=130</guid>

					<description><![CDATA[let gameOfLife = function(board) { if (!board) return []; let copy = [], LIVE = 1, DEAD = 0, maxRow = board.length - 1, maxCol = board[0].length - 1; function getAdjacentCount(row, col, valueToCompare) { let sum = 0; for (let i = Math.max(row - 1, 0); i &#60;= Math.min(row + 1, maxRow); i++) { for [&#8230;]]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-preformatted">let gameOfLife = function(board) {<br><br>    if (!board) return [];<br><br>    let copy = [],<br>        LIVE = 1,<br>        DEAD = 0,<br>        maxRow = board.length - 1,<br>        maxCol = board[0].length - 1;<br><br>    function getAdjacentCount(row, col, valueToCompare) {<br>        let sum = 0;<br>        for (let i = <strong><em>Math</em></strong>.max(row - 1, 0); i &lt;= <strong><em>Math</em></strong>.min(row + 1, maxRow); i++) {<br>            for (let j = <strong><em>Math</em></strong>.max(col - 1, 0); j &lt;= <strong><em>Math</em></strong>.min(col + 1, maxCol); j++) {<br>                if (i === row &amp;&amp; j === col) continue;<br>                if (copy[i] &amp;&amp; copy[i][j] !== undefined) {<br>                    if (copy[i][j] === valueToCompare) sum = sum + 1; //?<br>                }<br>                else {<br>                    if (board[i][j] === valueToCompare) sum = sum + 1; //?<br>                }<br>            }<br>        }<br>        return sum;<br>    }<br><br>    function getNextValue(row, col) {<br>        const val = board[row][col];<br>        let liveNeighbors = getAdjacentCount(row, col, LIVE);<br>        if (val === LIVE) {<br><br>            // Any live cell with fewer than two live neighbors dies, as if caused by under-population.<br>            if (liveNeighbors &lt; 2) {<br>                return DEAD;<br>            }<br>            // Any live cell with more than three live neighbors dies, as if by over-population..<br>            else if (liveNeighbors &gt; 3) {<br>                return DEAD;<br>            }<br>            // Any live cell with two or three live neighbors lives on to the next generation.<br>            return LIVE;<br>        }<br>        // cell is DEAD<br>        else {<br>            // Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.<br>            if (liveNeighbors === 3) {<br>                return LIVE;<br>            }<br>            // no condition<br>            return DEAD;<br>        }<br>    }<br><br>    for (let row = 0; row &lt;= maxRow; row++) {<br>        copy[row] = [];<br>        for (let col = 0; col &lt;= maxCol;col++) {<br>            copy[row][col] = board[row][col];<br>            board[row][col] = getNextValue(row, col);<br>        }<br>    }<br><br>};</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://jsalgorithm.com/2020/05/21/game-of-life/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">130</post-id>	</item>
		<item>
		<title>Array Plus One</title>
		<link>https://jsalgorithm.com/2020/05/20/array-plus-one/</link>
					<comments>https://jsalgorithm.com/2020/05/20/array-plus-one/#respond</comments>
		
		<dc:creator><![CDATA[Ronald]]></dc:creator>
		<pubDate>Wed, 20 May 2020 17:34:14 +0000</pubDate>
				<category><![CDATA[Array]]></category>
		<category><![CDATA[Leetcode]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[leetcode]]></category>
		<category><![CDATA[plusone]]></category>
		<guid isPermaLink="false">http://50.19.13.106/?p=128</guid>

					<description><![CDATA[let plusOne = function(digits) { let carry = 1; for (let i = digits.length - 1; i &#62;= 0; i--) { let sum = digits[i] + carry; if (sum &#62;= 10) { digits[i] = 0; carry = 1; } else { digits[i] = sum; carry = 0; } } if (carry === 1) digits.unshift(carry); return [&#8230;]]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-preformatted">let plusOne = function(digits) {<br><br>    let carry = 1;<br>    for (let i = digits.length - 1; i &gt;= 0; i--) {<br>        let sum = digits[i] + carry;<br>        if (sum &gt;= 10) {<br>            digits[i] = 0;<br>            carry = 1;<br>        }<br>        else {<br>            digits[i] = sum;<br>            carry = 0;<br>        }<br>    }<br><br>    if (carry === 1) digits.unshift(carry);<br><br>    return digits;<br>};</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://jsalgorithm.com/2020/05/20/array-plus-one/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">128</post-id>	</item>
		<item>
		<title>LinkedList Palindrome</title>
		<link>https://jsalgorithm.com/2020/05/20/linkedlist-palindrome/</link>
					<comments>https://jsalgorithm.com/2020/05/20/linkedlist-palindrome/#respond</comments>
		
		<dc:creator><![CDATA[Ronald]]></dc:creator>
		<pubDate>Wed, 20 May 2020 17:20:07 +0000</pubDate>
				<category><![CDATA[Leetcode]]></category>
		<category><![CDATA[Loop]]></category>
		<category><![CDATA[leetcode]]></category>
		<category><![CDATA[linkedlist]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[palindrome]]></category>
		<category><![CDATA[stack]]></category>
		<guid isPermaLink="false">http://50.19.13.106/?p=126</guid>

					<description><![CDATA[let isPalindrome = function(head) { let slow = head, fast = head, val = [slow.val]; while (fast.next) { if (fast.next.next) { fast = fast.next.next; slow = slow.next; val.push(slow.val); } else { fast = fast.next; slow = slow.next; } } while (slow) { if (slow.val !== val.pop()) { return false; } slow = slow.next; } return [&#8230;]]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-preformatted">let isPalindrome = function(head) {<br><br>    let slow = head, fast = head, val = [slow.val];<br><br>    while (fast.next) {<br>        if (fast.next.next) {<br>            fast = fast.next.next;<br>            slow = slow.next;<br>            val.push(slow.val);<br>        }<br>        else {<br>            fast = fast.next;<br>            slow = slow.next;<br>        }<br>    }<br><br>    while (slow) {<br>        if (slow.val !== val.pop()) {<br>            return false;<br>        }<br>        slow = slow.next;<br>    }<br><br>    return val.length === 0;<br>};</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://jsalgorithm.com/2020/05/20/linkedlist-palindrome/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">126</post-id>	</item>
		<item>
		<title>JS Algorithm Course</title>
		<link>https://jsalgorithm.com/2020/05/20/js-algorithm-course/</link>
					<comments>https://jsalgorithm.com/2020/05/20/js-algorithm-course/#respond</comments>
		
		<dc:creator><![CDATA[Ronald]]></dc:creator>
		<pubDate>Wed, 20 May 2020 15:18:06 +0000</pubDate>
				<category><![CDATA[Youtube]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[youtube]]></category>
		<guid isPermaLink="false">http://50.19.13.106/?p=124</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
httpss://www.youtube.com/watch?v=JgWm6sQwS_I
</div></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://jsalgorithm.com/2020/05/20/js-algorithm-course/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">124</post-id>	</item>
		<item>
		<title>Happy Number</title>
		<link>https://jsalgorithm.com/2020/05/20/happy-number/</link>
					<comments>https://jsalgorithm.com/2020/05/20/happy-number/#respond</comments>
		
		<dc:creator><![CDATA[Ronald]]></dc:creator>
		<pubDate>Wed, 20 May 2020 12:41:18 +0000</pubDate>
				<category><![CDATA[Leetcode]]></category>
		<category><![CDATA[Recursion]]></category>
		<category><![CDATA[leetcode]]></category>
		<category><![CDATA[recursion]]></category>
		<guid isPermaLink="false">http://50.19.13.106/?p=122</guid>

					<description><![CDATA[let isHappy = function(n) { let visited = {}; function sumOfSquare(num) { if (visited[num]) return false; visited[num] = true; let sum = 0; while (num &#62; 0) { let d = num % 10; //? num = Math.floor(num / 10); //? sum += d * d; } if (sum === 1) { return true; } [&#8230;]]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-preformatted">let isHappy = function(n) {<br>    let visited = {};<br><br>    function sumOfSquare(num) {<br>        if (visited[num]) return false;<br>        visited[num] = true;<br><br>        let sum = 0;<br>        while (num &gt; 0) {<br>            let d = num % 10; //?<br>            num = <strong><em>Math</em></strong>.floor(num / 10); //?<br>            sum += d * d;<br>        }<br><br>        if (sum === 1) {<br>            return true;<br>        }<br>        else {<br>            return sumOfSquare(sum);<br>        }<br>    }<br>    <br>    return sumOfSquare(n);<br>};</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://jsalgorithm.com/2020/05/20/happy-number/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">122</post-id>	</item>
		<item>
		<title>MaxStack</title>
		<link>https://jsalgorithm.com/2020/05/20/maxstack/</link>
					<comments>https://jsalgorithm.com/2020/05/20/maxstack/#respond</comments>
		
		<dc:creator><![CDATA[Ronald]]></dc:creator>
		<pubDate>Wed, 20 May 2020 03:15:12 +0000</pubDate>
				<category><![CDATA[Array]]></category>
		<category><![CDATA[Leetcode]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[leetcode]]></category>
		<guid isPermaLink="false">http://50.19.13.106/?p=120</guid>

					<description><![CDATA[class MaxStack { constructor() { this.results = []; this.sorted = []; } pop() { const val = this.results.pop(); this.sorted.splice(this.sorted.lastIndexOf(val), 1); return val; } push(x) { this.results.push(x); this.sorted = [...this.results].sort((x, y) =&#62; x - y); } top() { return this.results[this.results.length - 1]; } popMax() { const val = this.sorted.pop(); this.results.splice(this.results.lastIndexOf(val), 1); return val; } peekMax() { [&#8230;]]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-preformatted">class MaxStack {<br>    constructor() {<br>        this.results = [];<br>        this.sorted = [];<br>    }<br><br>    pop() {<br>        const val = this.results.pop();<br>        this.sorted.splice(this.sorted.lastIndexOf(val), 1);<br>        return val;<br>    }<br><br>    push(x) {<br>        this.results.push(x);<br>        this.sorted = [...this.results].sort((x, y) =&gt; x - y);<br>    }<br><br>    top() {<br>        return this.results[this.results.length - 1];<br>    }<br><br>    popMax() {<br>        const val = this.sorted.pop();<br>        this.results.splice(this.results.lastIndexOf(val), 1);<br>        return val;<br>    }<br><br>    peekMax() {<br>        return this.sorted[this.sorted.length - 1];<br>    }<br><br>}</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://jsalgorithm.com/2020/05/20/maxstack/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">120</post-id>	</item>
		<item>
		<title>MinStack</title>
		<link>https://jsalgorithm.com/2020/05/20/minstack/</link>
					<comments>https://jsalgorithm.com/2020/05/20/minstack/#respond</comments>
		
		<dc:creator><![CDATA[Ronald]]></dc:creator>
		<pubDate>Wed, 20 May 2020 03:03:29 +0000</pubDate>
				<category><![CDATA[Array]]></category>
		<category><![CDATA[Leetcode]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[leetcode]]></category>
		<guid isPermaLink="false">http://50.19.13.106/?p=118</guid>

					<description><![CDATA[class MinStack { constructor() { this.result = []; this.min = Number.MAX_SAFE_INTEGER; } push(x) { this.result.push(x) this.min = Math.min(x, this.min); }; pop() { let val = this.result.pop() if (val === this.min) { this.min = Math.min(...this.result); } }; top() { return this.result[this.result.length - 1]; }; getMin() { return this.min; };}]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-preformatted">class MinStack {<br>    constructor() {<br>        this.result = [];<br>        this.min = <strong><em>Number</em></strong>.MAX_SAFE_INTEGER;<br>    }<br><br>    push(x) {<br>        this.result.push(x)<br>        this.min = <strong><em>Math</em></strong>.min(x, this.min);<br>    };<br><br>    pop() {<br>        let val = this.result.pop()<br>        if (val === this.min) {<br>            this.min = <strong><em>Math</em></strong>.min(...this.result);<br>        }<br>    };<br><br>    top() {<br>        return this.result[this.result.length - 1];<br>    };<br><br>    getMin() {<br>        return this.min;<br>    };<br>}</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://jsalgorithm.com/2020/05/20/minstack/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">118</post-id>	</item>
	</channel>
</rss>
