<?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/"
	>

<channel>
	<title>O(n^3) Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/on3/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/tag/on3/</link>
	<description></description>
	<lastBuildDate>Sat, 14 Mar 2020 03:31:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.8</generator>

<image>
	<url>https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/cropped-photo-32x32.jpg</url>
	<title>O(n^3) Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/tag/on3/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>花花酱 LeetCode 375. Guess Number Higher or Lower II</title>
		<link>https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-375-guess-number-higher-or-lower-ii/</link>
					<comments>https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-375-guess-number-higher-or-lower-ii/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sat, 14 Mar 2020 03:22:21 +0000</pubDate>
				<category><![CDATA[Dynamic Programming]]></category>
		<category><![CDATA[dp]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[medium]]></category>
		<category><![CDATA[O(n^3)]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=6465</guid>

					<description><![CDATA[<p>We are playing the Guess Game. The game is as follows: I pick a number from&#160;1&#160;to&#160;n. You have to guess which number I picked. Every&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-375-guess-number-higher-or-lower-ii/">花花酱 LeetCode 375. Guess Number Higher or Lower II</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>We are playing the Guess Game. The game is as follows:</p>



<p>I pick a number from&nbsp;<strong>1</strong>&nbsp;to&nbsp;<strong>n</strong>. You have to guess which number I picked.</p>



<p>Every time you guess wrong, I&#8217;ll tell you whether the number I picked is higher or lower.</p>



<p>However, when you guess a particular number x, and you guess wrong, you pay&nbsp;<strong>$x</strong>. You win the game when you guess the number I picked.</p>



<p><strong>Example:</strong></p>



<pre class="wp-block-preformatted;crayon:false">n = 10, I pick 8.

First round:  You guess 5, I tell you that it's higher. You pay $5.
Second round: You guess 7, I tell you that it's higher. You pay $7.
Third round:  You guess 9, I tell you that it's lower. You pay $9.

Game over. 8 is the number I picked.

You end up paying $5 + $7 + $9 = $21.
</pre>



<p>Given a particular&nbsp;<strong>n ≥ 1</strong>, find out how much money you need to have to guarantee a&nbsp;<strong>win</strong>.</p>



<h2><strong>Solution: DP</strong></h2>



<p>Use dp[l][r] to denote the min money to win the game if the current guessing range is [l, r], to guarantee a win, we need to try all possible numbers in [l, r]. Let say we guess K, we need to pay K and the game might continue if we were wrong. cost will be K + max(dp(l, K-1), dp(K+1, r)), we need max to cover all possible cases. Among all Ks, we picked the cheapest one.</p>



<p>dp[l][r] = min(k + max(dp[l][k &#8211; 1], dp[k+1][r]), for l &lt;= k &lt;= r.</p>



<p>Time complexity: O(n^3)<br>Space complexity: O(n^2)</p>



<div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">// Author: Huahua
class Solution {
public:
  int getMoneyAmount(int n) {
    constexpr int kInf = 1e9;
    vector&lt;vector&lt;int&gt;&gt; cache(n + 2, vector&lt;int&gt;(n + 2, kInf));
    function&lt;int(int, int)&gt; dp = [&amp;](int l, int r) {
      int&amp; ans = cache[l][r];
      if (l &gt;= r) return 0;
      if (ans != kInf) return ans;
      for (int x = l; x &lt;= r; ++x)
        ans = min(ans, x + max(dp(l, x - 1), dp(x + 1, r)));
      return ans;
    };
    return dp(1, n);
  }
};</pre>
</div></div>



<div class="responsive-tabs">
<h2 class="tabtitle">Python3</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag"># Author: Huahua
class Solution:
  def getMoneyAmount(self, n: int) -&gt; int:
    @lru_cache(maxsize=None)
    def dp(l, r):      
      return min([k + max(dp(l, k - 1), dp(k + 1, r)) 
                  for k in range(l, r + 1)]) if l &lt; r else 0
    return dp(1, n)</pre>
</div></div>



<p></p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-375-guess-number-higher-or-lower-ii/">花花酱 LeetCode 375. Guess Number Higher or Lower II</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-375-guess-number-higher-or-lower-ii/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 LeetCode 1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance</title>
		<link>https://zxi.mytechroad.com/blog/graph/leetcode-1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/</link>
					<comments>https://zxi.mytechroad.com/blog/graph/leetcode-1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Mon, 27 Jan 2020 06:58:54 +0000</pubDate>
				<category><![CDATA[Graph]]></category>
		<category><![CDATA[dijkstra]]></category>
		<category><![CDATA[dp]]></category>
		<category><![CDATA[floyd-warshall]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[medium]]></category>
		<category><![CDATA[O(n^3)]]></category>
		<category><![CDATA[shortest path]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=6149</guid>

					<description><![CDATA[<p>There are&#160;n&#160;cities numbered from&#160;0&#160;to&#160;n-1. Given the array&#160;edges&#160;where&#160;edges[i] = [fromi, toi, weighti]&#160;represents a bidirectional and weighted edge between cities&#160;fromi&#160;and&#160;toi, and given the integer&#160;distanceThreshold. Return the city&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/graph/leetcode-1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/">花花酱 LeetCode 1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="花花酱 LeetCode 1334. Find the City With the Smallest Number of Neighbors - 刷题找工作 EP303" width="500" height="375" src="https://www.youtube.com/embed/iE0tJ-8rPLQ?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div></figure>



<p>There are&nbsp;<code>n</code>&nbsp;cities numbered from&nbsp;<code>0</code>&nbsp;to&nbsp;<code>n-1</code>. Given the array&nbsp;<code>edges</code>&nbsp;where&nbsp;<code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code>&nbsp;represents a bidirectional and weighted edge between cities&nbsp;<code>from<sub>i</sub></code>&nbsp;and&nbsp;<code>to<sub>i</sub></code>, and given the integer&nbsp;<code>distanceThreshold</code>.</p>



<p>Return the city with the smallest numberof&nbsp;cities that are reachable through some path and whose distance is&nbsp;<strong>at most</strong>&nbsp;<code>distanceThreshold</code>, If there are multiple such cities, return the city with the greatest number.</p>



<p>Notice that the distance of a path connecting cities&nbsp;<em><strong>i</strong></em>&nbsp;and&nbsp;<em><strong>j</strong></em>&nbsp;is equal to the sum of the edges&#8217; weights along that path.</p>



<p><strong>Example 1:</strong></p>



<figure class="wp-block-image"><img src="https://assets.leetcode.com/uploads/2020/01/16/find_the_city_01.png" alt=""/></figure>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> n = 4, edges = [[0,1,3],[1,2,1],[1,3,4],[2,3,1]], distanceThreshold = 4
<strong>Output:</strong> 3
<strong>Explanation: </strong>The figure above describes the graph.&nbsp;
The neighboring cities at a distanceThreshold = 4 for each city are:
City 0 -&gt; [City 1, City 2]&nbsp;
City 1 -&gt; [City 0, City 2, City 3]&nbsp;
City 2 -&gt; [City 0, City 1, City 3]&nbsp;
City 3 -&gt; [City 1, City 2]&nbsp;
Cities 0 and 3 have 2 neighboring cities at a distanceThreshold = 4, but we have to return city 3 since it has the greatest number.
</pre>



<p><strong>Example 2:</strong></p>



<figure class="wp-block-image"><img src="https://assets.leetcode.com/uploads/2020/01/16/find_the_city_02.png" alt=""/></figure>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> n = 5, edges = [[0,1,2],[0,4,8],[1,2,3],[1,4,2],[2,3,1],[3,4,1]], distanceThreshold = 2
<strong>Output:</strong> 0
<strong>Explanation: </strong>The figure above describes the graph.&nbsp;
The neighboring cities at a distanceThreshold = 2 for each city are:
City 0 -&gt; [City 1]&nbsp;
City 1 -&gt; [City 0, City 4]&nbsp;
City 2 -&gt; [City 3, City 4]&nbsp;
City 3 -&gt; [City 2, City 4]
City 4 -&gt; [City 1, City 2, City 3]&nbsp;
The city 0 has 1 neighboring city at a distanceThreshold = 2.
</pre>



<p><strong>Constraints:</strong></p>



<ul><li><code>2 &lt;= n &lt;= 100</code></li><li><code>1 &lt;= edges.length &lt;= n * (n - 1) / 2</code></li><li><code>edges[i].length == 3</code></li><li><code>0 &lt;= from<sub>i</sub>&nbsp;&lt; to<sub>i</sub>&nbsp;&lt; n</code></li><li><code>1 &lt;= weight<sub>i</sub>,&nbsp;distanceThreshold &lt;= 10^4</code></li><li>All pairs&nbsp;<code>(from<sub>i</sub>, to<sub>i</sub>)</code>&nbsp;are distinct.</li></ul>



<figure class="wp-block-image"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/01/1334-ep303-1.png" alt="" class="wp-image-6163" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/01/1334-ep303-1.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/01/1334-ep303-1-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/01/1334-ep303-1-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<h2><strong>Solution1: Floyd-Warshall</strong></h2>



<p>All pair shortest path</p>



<p>Time complexity: O(n^3)<br>Space complexity: O(n^2)</p>



<div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">// Author: Huahua
class Solution {
public:
  int findTheCity(int n, vector&lt;vector&lt;int&gt;&gt;&amp; edges, int distanceThreshold) {
    vector&lt;vector&lt;int&gt;&gt; dp(n, vector&lt;int&gt;(n, INT_MAX / 2));
    for (const auto&amp; e : edges)      
      dp[e[0]][e[1]] = dp[e[1]][e[0]] = e[2];    
    
    for (int k = 0; k &lt; n; ++k)
      for (int u = 0; u &lt; n; ++u)
        for (int v = 0; v &lt; n; ++v)
          dp[u][v] = min(dp[u][v], dp[u][k] + dp[k][v]);
    
    int ans = -1;
    int min_nb = INT_MAX;
    for (int u = 0; u &lt; n; ++u) {
      int nb = 0;
      for (int v = 0; v &lt; n; ++v)
        if (v != u &amp;&amp; dp[u][v] &lt;= distanceThreshold)
          ++nb;
      if (nb &lt;= min_nb) {
        min_nb = nb;
        ans = u;
      }
    }
    
    return ans;
  }
};</pre>
</div></div>



<p><strong>Solution 2: Dijkstra&#8217;s Algorithm</strong></p>



<p>Time complexity: O(V * ElogV) / worst O(n^3*logn), best O(n^2*logn)<br>Space complexity: O(V + E)</p>



<div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">// Author: Huahua
// Author: Huahua
class Solution {
public:
  int findTheCity(int n, vector&lt;vector&lt;int&gt;&gt;&amp; edges, int t) {
    vector&lt;vector&lt;pair&lt;int, int&gt;&gt;&gt; g(n);
    for (const auto&amp; e : edges) {
      g[e[0]].emplace_back(e[1], e[2]);
      g[e[1]].emplace_back(e[0], e[2]);
    }
    
    // Returns the number of nodes within t from s.
    auto dijkstra = [&amp;](int s) {
      vector&lt;int&gt; dist(n, INT_MAX / 2);
      set&lt;pair&lt;int, int&gt;&gt; q; // &lt;dist, node&gt;
      vector&lt;set&lt;pair&lt;int, int&gt;&gt;::const_iterator&gt; its(n);
      dist[s] = 0;
      for (int i = 0; i &lt; n; ++i)
        its[i] = q.emplace(dist[i], i).first;
      while (!q.empty()) {
        auto it = cbegin(q);
        int d = it-&gt;first;
        int u = it-&gt;second;
        q.erase(it);        
        if (d &gt; t) break; // pruning
        for (const auto&amp; p : g[u]) {
          int v = p.first;
          int w = p.second;
          if (dist[v] &lt;= d + w) continue;
          // Decrease key
          q.erase(its[v]);
          its[v] = q.emplace(dist[v] = d + w, v).first;
        }
      }
      return count_if(begin(dist), end(dist), [t](int d) { return d &lt;= t; });
    };
    
    int ans = -1;
    int min_nb = INT_MAX;
    for (int i = 0; i &lt; n; ++i) {
      int nb = dijkstra(i);
      if (nb &lt;= min_nb) {
        min_nb = nb;
        ans = i;
      }
    }
    
    return ans;
  }
};</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/graph/leetcode-1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/">花花酱 LeetCode 1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/graph/leetcode-1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 LeetCode 664. Strange Printer</title>
		<link>https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-664-strange-printer/</link>
					<comments>https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-664-strange-printer/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Thu, 21 Sep 2017 06:15:24 +0000</pubDate>
				<category><![CDATA[Dynamic Programming]]></category>
		<category><![CDATA[dp]]></category>
		<category><![CDATA[hard]]></category>
		<category><![CDATA[O(n^3)]]></category>
		<category><![CDATA[printer]]></category>
		<category><![CDATA[sequence]]></category>
		<guid isPermaLink="false">http://zxi.mytechroad.com/blog/?p=379</guid>

					<description><![CDATA[<p>Problem: There is a strange printer with the following two special requirements: The printer can only print a sequence of the same character each time.&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-664-strange-printer/">花花酱 LeetCode 664. Strange Printer</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><iframe width="500" height="375" src="https://www.youtube.com/embed/YQQUGsb7mww?feature=oembed" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></p>
<p><strong>Problem:</strong></p>
<p>There is a strange printer with the following two special requirements:</p>
<ol>
<li>The printer can only print a sequence of the same character each time.</li>
<li>At each turn, the printer can print new characters starting from and ending at any places, and will cover the original existing characters.</li>
</ol>
<p>Given a string consists of lower English letters only, your job is to count the minimum number of turns the printer needed in order to print it.</p>
<p><b>Example 1:</b></p><pre class="crayon-plain-tag">Input: &quot;aaabbb&quot;
Output: 2
Explanation: Print &quot;aaa&quot; first and then print &quot;bbb&quot;.</pre><p><b>Example 2:</b></p><pre class="crayon-plain-tag">Input: &quot;aba&quot;
Output: 2
Explanation: Print &quot;aaa&quot; first and then print &quot;b&quot; from the second place of the string, which will cover the existing character 'a'.</pre><p><b>Hint</b>: Length of the given string will not exceed 100.</p>
<p><strong>Idea:</strong></p>
<p>Dynamic programming</p>
<p><a href="http://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/664-ep66.png"><img class="alignnone size-full wp-image-380" src="http://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/664-ep66.png" alt="" width="960" height="540" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/664-ep66.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/664-ep66-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/664-ep66-768x432.png 768w, https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/664-ep66-624x351.png 624w" sizes="(max-width: 960px) 100vw, 960px" /></a></p>
<p><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" style="display: block; text-align: center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-2404451723245401" data-ad-slot="7983117522"></ins><br />
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script></p>
<p><strong>Time Complexity: </strong></p>
<p>O(n^3)</p>
<p><strong>Space Complexity:</strong></p>
<p>O(n^2)</p>
<p><strong>Solution:</strong></p>
<p><div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">
</p><pre class="crayon-plain-tag">// Author: Huahua
// Time Complexity: O(n^3)
// Space Complexity: O(n^2)
// Running Time: 22 ms
class Solution {
public:
    int strangePrinter(const string&amp; s) {
        int l = s.length();
        t_ = vector&lt;vector&lt;int&gt;&gt;(l, vector&lt;int&gt;(l, 0));
        return turn(s, 0, s.length() - 1);
    }
private:
    // Minimal turns to print s[i] to s[j] 
    int turn(const string&amp; s, int i, int j) {
        // Empty string
        if (i &gt; j) return 0;        
        // Solved
        if (t_[i][j] &gt; 0) return t_[i][j];
        
        // Default behavior, print s[i] to s[j-1] and print s[j]
        int ans = turn(s, i, j-1) + 1;
        
        for (int k = i; k &lt; j; ++k)
            if (s[k] == s[j])
                ans = min(ans, turn(s, i, k) + turn(s, k + 1, j - 1));
        
        return t_[i][j] = ans;
    }
    
    vector&lt;vector&lt;int&gt;&gt; t_;
    
};</pre><p></div><h2 class="tabtitle">Java</h2>
<div class="tabcontent">
</p><pre class="crayon-plain-tag">// Author: Huahua
// Time Complexity: O(n^3)
// Space Complexity: O(n^2)
// Running Time: 31 ms (beat 99.25%) 9/2017
class Solution {
    public int strangePrinter(String s) {
        int l = s.length();
        t_ = new int[l][l];
        return turn(s.toCharArray(), 0, l - 1);
    }
    
    // Minimal turns to print s[i] to s[j] 
    private int turn(char[] s, int i, int j) {
        // Empty string
        if (i &gt; j) return 0;        
        // Solved
        if (t_[i][j] &gt; 0) return t_[i][j];
        // Default behavior, print s[i] to s[j-1] and print s[j]
        int ans = turn(s, i, j-1) + 1;        
        for (int k = i; k &lt; j; ++k)
            if (s[k] == s[j])
                ans = Math.min(ans, turn(s, i, k) + turn(s, k + 1, j - 1));
        
        return t_[i][j] = ans;
    }
        
    private int[][] t_;    
}</pre><p></div><h2 class="tabtitle">Python3</h2>
<div class="tabcontent">
</p><pre class="crayon-plain-tag">"""
Author: Huahua
Time Complexity: O(n^3)
Space Complexity: O(n^2)
Running Time: 895 ms (beat 66%) 9/2017
"""
class Solution(object):
    def strangePrinter(self, s):
        """
        :type s: str
        :rtype: int
        """
        l = len(s)
        self._t = [[0 for _ in xrange(l)] for _ in xrange(l)]
        
        return self._turns(s, 0, l - 1)
    
    def _turns(self, s, i, j):
        if i &gt; j: return 0
        if self._t[i][j] &gt; 0: return self._t[i][j]
        
        ans = self._turns(s, i, j - 1) + 1
        
        for k in xrange(i, j):
            if s[k] == s[j]:
                ans = min(ans, self._turns(s, i, k) 
                             + self._turns(s, k + 1, j-1))
        self._t[i][j] = ans
        
        return self._t[i][j]</pre><p></div></div></p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-664-strange-printer/">花花酱 LeetCode 664. Strange Printer</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-664-strange-printer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
