<?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>template Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/template/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/tag/template/</link>
	<description></description>
	<lastBuildDate>Sun, 29 Dec 2019 18:39:21 +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>template Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/tag/template/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Binary search template 二分搜索模板</title>
		<link>https://zxi.mytechroad.com/blog/template/binary-search-template/</link>
					<comments>https://zxi.mytechroad.com/blog/template/binary-search-template/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sun, 29 Dec 2019 10:03:36 +0000</pubDate>
				<category><![CDATA[Template]]></category>
		<category><![CDATA[binary search]]></category>
		<category><![CDATA[O(logn)]]></category>
		<category><![CDATA[template]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=6012</guid>

					<description><![CDATA[<p>[crayon-663c938b6fcc4637679691/] [crayon-663c938b6fcc8683766455/] Related Articles https://zxi.mytechroad.com/blog/sp/sp5-binary-search/ https://zxi.mytechroad.com/blog/sp/binary-search-ii-sp17/</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/template/binary-search-template/">Binary search template 二分搜索模板</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div class="responsive-tabs">
<h2 class="tabtitle">Python</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag"># Author: Huahua
# Returns the smallest m in [l, r),
# s.t. cond(m) == True
# If not found returns r.
def binarySearch(l, r)
  while l &lt; r:
    m = l + (r - l) // 2
    if cond(m):
      r = m
    else
      l = m + 1
  return l</pre>
</div></div>



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

<pre class="crayon-plain-tag">// Author: Huahua
// Returns the smallest m in [l, r),
// s.t. cond(m) == True
// If not found returns r.
int binarySearch(int l, int r) {
  while (l &lt; r) {
    int m = l + (r - l) / 2;
    if (cond(m)) r = m;
    else l = m + 1;
  }
  return l;
}</pre>
</div></div>



<h2><strong>Related Articles</strong></h2>



<ul><li><a href="https://zxi.mytechroad.com/blog/sp/sp5-binary-search/">https://zxi.mytechroad.com/blog/sp/sp5-binary-search/</a></li><li><a href="https://zxi.mytechroad.com/blog/sp/binary-search-ii-sp17/">https://zxi.mytechroad.com/blog/sp/binary-search-ii-sp17/</a></li></ul>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/template/binary-search-template/">Binary search template 二分搜索模板</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/template/binary-search-template/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 LeetCode DP Summary 动态规划总结</title>
		<link>https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-dp-summary/</link>
					<comments>https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-dp-summary/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Fri, 02 Nov 2018 06:18:52 +0000</pubDate>
				<category><![CDATA[Dynamic Programming]]></category>
		<category><![CDATA[SP]]></category>
		<category><![CDATA[dp]]></category>
		<category><![CDATA[summary]]></category>
		<category><![CDATA[template]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=4233</guid>

					<description><![CDATA[<p>Summary: Input size / sub-problem size / sub-problem complexity / time complexity / space complexity [crayon-663c938b70089108901389/] [crayon-663c938b7008c604778609/] &#160; Summary and slides</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-dp-summary/">花花酱 LeetCode DP Summary 动态规划总结</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/3mY5W0yojtA?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p>
<p><iframe width="500" height="375" src="https://www.youtube.com/embed/eLlZEYzZVyQ?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p>
<p>Summary: Input size / sub-problem size / sub-problem complexity / time complexity / space complexity</p>
<p><div class="responsive-tabs">
<h2 class="tabtitle">Category 1.1</h2>
<div class="tabcontent">
</p><pre class="crayon-plain-tag">Input: O(n)
Sub-problems: O(n)
Each sub-problem depends on O(1) smaller problems
Time complexity: O(n)
Space complexity: O(n) -&gt; O(1)
dp[i] := solution of A[1-&gt;i] // prefix</pre><p></div><h2 class="tabtitle">Template</h2>
<div class="tabcontent">
</p><pre class="crayon-plain-tag">dp = new int[n + 1]
for i = 1 to n:
  dp[i] = f(A[i], dp[i-1], dp[i-2], ...)
return dp[n]</pre><p></div></div></p>
<p>&nbsp;</p>
<p>Summary and slides</p>
<p><img class="alignnone size-full wp-image-4234" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-1.png" alt="" width="960" height="540" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-1.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-1-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-1-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></p>
<p><img class="alignnone size-full wp-image-4235" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-2.png" alt="" width="960" height="540" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-2.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-2-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-2-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></p>
<p><img class="alignnone size-large wp-image-4236" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-3.png" alt="" width="960" height="540" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-3.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-3-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-3-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></p>
<p><img class="alignnone size-large wp-image-4237" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-4.png" alt="" width="960" height="540" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-4.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-4-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-4-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></p>
<p><img class="alignnone wp-image-4244 size-full" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-5.png" alt="" width="960" height="540" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-5.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-5-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-5-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></p>
<p><img class="alignnone size-large wp-image-4239" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-6.png" alt="" width="960" height="540" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-6.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-6-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-6-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></p>
<p><img class="alignnone size-large wp-image-4240" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-7.png" alt="" width="960" height="540" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-7.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-7-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2018/11/sp9-7-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-dp-summary/">花花酱 LeetCode DP Summary 动态规划总结</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-dp-summary/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
