<?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(logn) Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/ologn/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/tag/ologn/</link>
	<description></description>
	<lastBuildDate>Sun, 13 Dec 2020 20:17:02 +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(logn) Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/tag/ologn/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>花花酱 LeetCode 1688. Count of Matches in Tournament</title>
		<link>https://zxi.mytechroad.com/blog/simulation/leetcode-1688-count-of-matches-in-tournament/</link>
					<comments>https://zxi.mytechroad.com/blog/simulation/leetcode-1688-count-of-matches-in-tournament/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sun, 13 Dec 2020 20:15:36 +0000</pubDate>
				<category><![CDATA[Recursion]]></category>
		<category><![CDATA[Simulation]]></category>
		<category><![CDATA[easy]]></category>
		<category><![CDATA[O(logn)]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[simulation]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=7799</guid>

					<description><![CDATA[<p>You are given an integer&#160;n, the number of teams in a tournament that has strange rules: If the current number of teams is&#160;even, each team&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/simulation/leetcode-1688-count-of-matches-in-tournament/">花花酱 LeetCode 1688. Count of Matches in Tournament</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>You are given an integer&nbsp;<code>n</code>, the number of teams in a tournament that has strange rules:</p>



<ul><li>If the current number of teams is&nbsp;<strong>even</strong>, each team gets paired with another team. A total of&nbsp;<code>n / 2</code>&nbsp;matches are played, and&nbsp;<code>n / 2</code>&nbsp;teams advance to the next round.</li><li>If the current number of teams is&nbsp;<strong>odd</strong>, one team randomly advances in the tournament, and the rest gets paired. A total of&nbsp;<code>(n - 1) / 2</code>&nbsp;matches are played, and&nbsp;<code>(n - 1) / 2 + 1</code>&nbsp;teams advance to the next round.</li></ul>



<p>Return&nbsp;<em>the number of matches played in the tournament until a winner is decided.</em></p>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> n = 7
<strong>Output:</strong> 6
<strong>Explanation:</strong> Details of the tournament: 
- 1st Round: Teams = 7, Matches = 3, and 4 teams advance.
- 2nd Round: Teams = 4, Matches = 2, and 2 teams advance.
- 3rd Round: Teams = 2, Matches = 1, and 1 team is declared the winner.
Total number of matches = 3 + 2 + 1 = 6.
</pre>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> n = 14
<strong>Output:</strong> 13
<strong>Explanation:</strong> Details of the tournament:
- 1st Round: Teams = 14, Matches = 7, and 7 teams advance.
- 2nd Round: Teams = 7, Matches = 3, and 4 teams advance.
- 3rd Round: Teams = 4, Matches = 2, and 2 teams advance.
- 4th Round: Teams = 2, Matches = 1, and 1 team is declared the winner.
Total number of matches = 7 + 3 + 2 + 1 = 13.
</pre>



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



<ul><li><code>1 &lt;= n &lt;= 200</code></li></ul>



<h2><strong>Solution: Simulation / Recursion</strong></h2>



<p>Time complexity: O(logn)<br>Space complexity: O(1)</p>



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

<pre class="crayon-plain-tag">// Ver 1
class Solution {
public:
  int numberOfMatches(int n) {
    int ans = 0;
    while (n &amp;gt; 1) {
      ans += n / 2 + (n &amp; 1);
      n /= 2;
    }
    return ans;
  }
};
// Ver 2
class Solution {
public:
  int numberOfMatches(int n) {
    return n &amp;gt; 1 ? n / 2 + (n &amp; 1) + numberOfMatches(n / 2) : 0;
  }
};</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/simulation/leetcode-1688-count-of-matches-in-tournament/">花花酱 LeetCode 1688. Count of Matches in Tournament</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/simulation/leetcode-1688-count-of-matches-in-tournament/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 LeetCode 365. Water and Jug Problem</title>
		<link>https://zxi.mytechroad.com/blog/math/leetcode-365-water-and-jug-problem/</link>
					<comments>https://zxi.mytechroad.com/blog/math/leetcode-365-water-and-jug-problem/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Mon, 09 Mar 2020 07:52:12 +0000</pubDate>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[gcd]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[medium]]></category>
		<category><![CDATA[O(logn)]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=6432</guid>

					<description><![CDATA[<p>You are given two jugs with capacities&#160;x&#160;and&#160;y&#160;litres. There is an infinite amount of water supply available. You need to determine whether it is possible to&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/math/leetcode-365-water-and-jug-problem/">花花酱 LeetCode 365. Water and Jug Problem</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>You are given two jugs with capacities&nbsp;<em>x</em>&nbsp;and&nbsp;<em>y</em>&nbsp;litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly&nbsp;<em>z</em>&nbsp;litres using these two jugs.</p>



<p>If&nbsp;<em>z</em>&nbsp;liters of water is measurable, you must have&nbsp;<em>z</em>&nbsp;liters of water contained within&nbsp;<strong>one or both buckets</strong>&nbsp;by the end.</p>



<p>Operations allowed:</p>



<ul><li>Fill any of the jugs completely with water.</li><li>Empty any of the jugs.</li><li>Pour water from one jug into another till the other jug is completely full or the first jug itself is empty.</li></ul>



<p><strong>Example 1:</strong>&nbsp;(From the famous&nbsp;<a href="https://www.youtube.com/watch?v=BVtQNK_ZUJg" target="_blank" rel="noreferrer noopener"><em>&#8220;Die Hard&#8221;</em>&nbsp;example</a>)</p>



<pre class="wp-block-preformatted;crayon:false">Input: x = 3, y = 5, z = 4
Output: True
</pre>



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



<pre class="wp-block-preformatted;crayon:false">Input: x = 2, y = 6, z = 5
Output: False</pre>



<h2><strong>Solution: Math</strong></h2>



<p>special case 1: x == z or y == z or x + y == z: return True<br>special case 2: x + y &lt; z: return False<br>normal case: z must be a factor of gcd(x, y)</p>



<p>Time complexity: O(log(min(x, y))<br>Space complexity: O(1)</p>



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

<pre class="crayon-plain-tag">// Author: Huahua
class Solution {
public:
  bool canMeasureWater(int x, int y, int z) {
    if (x == z || y == z || x + y == z) return true;
    if (x + y &lt; z) return false;
    return z % gcd(x, y) == 0;
  }
};</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/math/leetcode-365-water-and-jug-problem/">花花酱 LeetCode 365. Water and Jug Problem</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/math/leetcode-365-water-and-jug-problem/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 LeetCode 162. Find Peak Element</title>
		<link>https://zxi.mytechroad.com/blog/algorithms/binary-search/%e8%8a%b1%e8%8a%b1%e9%85%b1-leetcode-162-find-peak-element/</link>
					<comments>https://zxi.mytechroad.com/blog/algorithms/binary-search/%e8%8a%b1%e8%8a%b1%e9%85%b1-leetcode-162-find-peak-element/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sat, 01 Feb 2020 07:05:06 +0000</pubDate>
				<category><![CDATA[Binary Search]]></category>
		<category><![CDATA[binary search]]></category>
		<category><![CDATA[medium]]></category>
		<category><![CDATA[O(logn)]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=6216</guid>

					<description><![CDATA[<p>A peak element is an element that is greater than its neighbors. Given an input array&#160;nums, where&#160;nums[i] ≠ nums[i+1], find a peak element and return&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/algorithms/binary-search/%e8%8a%b1%e8%8a%b1%e9%85%b1-leetcode-162-find-peak-element/">花花酱 LeetCode 162. Find Peak Element</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>A peak element is an element that is greater than its neighbors.</p>



<p>Given an input array&nbsp;<code>nums</code>, where&nbsp;<code>nums[i] ≠ nums[i+1]</code>, find a peak element and return its index.</p>



<p>The array may contain multiple peaks, in that case return the index to any one of the peaks is fine.</p>



<p>You may imagine that&nbsp;<code>nums[-1] = nums[n] = -∞</code>.</p>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> <strong>nums</strong> = <code>[1,2,3,1]</code>
<strong>Output:</strong> 2
<strong>Explanation:</strong> 3 is a peak element and your function should return the index number 2.</pre>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> <strong>nums</strong> = <code>[</code>1,2,1,3,5,6,4]
<strong>Output:</strong> 1 or 5 
<strong>Explanation:</strong> Your function can return either index number 1 where the peak element is 2, or index number 5 where the peak element is 6.</pre>



<h2><strong>Solution: Binary Search</strong></h2>



<p>Time complexity: O(logn)<br>Space complexity: O(1)</p>



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

<pre class="crayon-plain-tag">// Author: Huahua
class Solution {
public:
  int findPeakElement(const vector&lt;int&gt; &amp;num) {
    int l = 0, r = num.size() - 1; // preventing OOB
    while (l &lt; r) {
      int m = l + (r - l) / 2;
      // Find the first m s.t. num[m] &gt; num[m + 1]
      if (num[m] &gt; num[m + 1])
        r = m;
      else
        l = m + 1;
    }
    return l;
  }
};</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/algorithms/binary-search/%e8%8a%b1%e8%8a%b1%e9%85%b1-leetcode-162-find-peak-element/">花花酱 LeetCode 162. Find Peak Element</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/algorithms/binary-search/%e8%8a%b1%e8%8a%b1%e9%85%b1-leetcode-162-find-peak-element/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<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-663eacf80830b341651101/] [crayon-663eacf80830e809287939/] 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 1201. Ugly Number III</title>
		<link>https://zxi.mytechroad.com/blog/algorithms/binary-search/leetcode-1201-ugly-number-iii/</link>
					<comments>https://zxi.mytechroad.com/blog/algorithms/binary-search/leetcode-1201-ugly-number-iii/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sun, 22 Sep 2019 08:34:14 +0000</pubDate>
				<category><![CDATA[Binary Search]]></category>
		<category><![CDATA[binary search]]></category>
		<category><![CDATA[gcd]]></category>
		<category><![CDATA[lcm]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[medium]]></category>
		<category><![CDATA[O(logn)]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=5565</guid>

					<description><![CDATA[<p>Write a program to find the&#160;n-th ugly number. Ugly numbers are&#160;positive integers&#160;which are divisible by&#160;a&#160;or&#160;b&#160;or&#160;c. Example 1: Input: n = 3, a = 2, b&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/algorithms/binary-search/leetcode-1201-ugly-number-iii/">花花酱 LeetCode 1201. Ugly Number III</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 width="500" height="375" src="https://www.youtube.com/embed/gj4JevBj8-Y?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div></figure>



<p>Write a program to find the&nbsp;<code>n</code>-th ugly number.</p>



<p>Ugly numbers are<strong>&nbsp;positive integers</strong>&nbsp;which are divisible by&nbsp;<code>a</code>&nbsp;<strong>or</strong>&nbsp;<code>b</code>&nbsp;<strong>or</strong>&nbsp;<code>c</code>.</p>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> n = 3, a = 2, b = 3, c = 5
<strong>Output:</strong> 4
<strong>Explanation: </strong>The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3rd is 4.</pre>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> n = 4, a = 2, b = 3, c = 4
<strong>Output:</strong> 6
<strong>Explanation: </strong>The ugly numbers are 2, 3, 4, 6, 8, 9, 12... The 4th is 6.
</pre>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> n = 5, a = 2, b = 11, c = 13
<strong>Output:</strong> 10
<strong>Explanation: </strong>The ugly numbers are 2, 4, 6, 8, 10, 11, 12, 13... The 5th is 10.
</pre>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> n = 1000000000, a = 2, b = 217983653, c = 336916467
<strong>Output:</strong> 1999999984
</pre>



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



<ul><li><code>1 &lt;= n, a, b, c &lt;= 10^9</code></li><li><code>1 &lt;= a * b * c &lt;= 10^18</code></li><li>It&#8217;s guaranteed that the result will be in range&nbsp;<code>[1,&nbsp;2 * 10^9]</code></li></ul>



<h2><strong>Solution: Binary Search</strong></h2>



<figure class="wp-block-image"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2019/09/1201-ep270.png" alt="" class="wp-image-5582" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2019/09/1201-ep270.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2019/09/1201-ep270-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2019/09/1201-ep270-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<p>Number of ugly numbers that are &lt;= m are:</p>



<p>m / a + m / b + m / c &#8211; (m / LCM(a,b) + m / LCM(a, c) + m / LCM(b, c) + m / LCM(a, LCM(b, c))</p>



<p>Time complexity: O(logn)<br>Space complexity: O(1)</p>



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

<pre class="crayon-plain-tag">// Author: Huahua
class Solution {
public:
  int nthUglyNumber(int n, long a, long b, long c) {    
    long l = 1;
    long r = INT_MAX;
    long ab = lcm(a, b);
    long ac = lcm(a, c);
    long bc = lcm(b, c);
    long abc = lcm(a, bc);
    while (l &lt; r) {
      long m = l + (r - l) / 2;
      long k = m / a + m / b + m / c - m / ab - m / ac - m / bc + m / abc;      
      if (k &gt;= n) r = m;
      else l = m + 1;
    }
    return l;
  }
};</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/algorithms/binary-search/leetcode-1201-ugly-number-iii/">花花酱 LeetCode 1201. Ugly Number III</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/algorithms/binary-search/leetcode-1201-ugly-number-iii/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 LeetCode 34. Find First and Last Position of Element in Sorted Array</title>
		<link>https://zxi.mytechroad.com/blog/algorithms/binary-search/leetcode-34-find-first-and-last-position-of-element-in-sorted-array/</link>
					<comments>https://zxi.mytechroad.com/blog/algorithms/binary-search/leetcode-34-find-first-and-last-position-of-element-in-sorted-array/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Tue, 20 Aug 2019 21:12:46 +0000</pubDate>
				<category><![CDATA[Binary Search]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[binary search]]></category>
		<category><![CDATA[O(logn)]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=5455</guid>

					<description><![CDATA[<p>Given an array of integers&#160;nums&#160;sorted in ascending order, find the starting and ending position of a given&#160;target&#160;value. Your algorithm&#8217;s runtime complexity must be in the&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/algorithms/binary-search/leetcode-34-find-first-and-last-position-of-element-in-sorted-array/">花花酱 LeetCode 34. Find First and Last Position of Element in Sorted Array</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>Given an array of integers&nbsp;<code>nums</code>&nbsp;sorted in ascending order, find the starting and ending position of a given&nbsp;<code>target</code>&nbsp;value.</p>



<p>Your algorithm&#8217;s runtime complexity must be in the order of&nbsp;<em>O</em>(log&nbsp;<em>n</em>).</p>



<p>If the target is not found in the array, return&nbsp;<code>[-1, -1]</code>.</p>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> nums = [<code>5,7,7,8,8,10]</code>, target = 8
<strong>Output:</strong> [3,4]</pre>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> nums = [<code>5,7,7,8,8,10]</code>, target = 6
<strong>Output:</strong> [-1,-1]</pre>



<h2><strong>Solution: Binary Search</strong></h2>



<p>Basically this problem asks you to implement lower_bound and upper_bound using binary search.</p>



<p>Time complexity: O(logn)<br>Space complexity: O(1)</p>



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

<pre class="crayon-plain-tag">// Author: Huahua
class Solution {
public:
  vector&lt;int&gt; searchRange(vector&lt;int&gt;&amp; nums, int target) {
    return {firstPos(nums, target), lastPos(nums, target)};
  }
private:
  int firstPos(const vector&lt;int&gt;&amp; nums, int target) {
    int l = 0;
    int r = nums.size();
    while (l &lt; r) {
      int m = l + (r - l) / 2;      
      if (nums[m] &gt;= target) {
        r = m;
      } else {
        l = m + 1;
      }
    }
    
    if (l == nums.size() || nums[l] != target) return -1;
    return l;    
  }

  int lastPos(const vector&lt;int&gt;&amp; nums, int target) {
    int l = 0;
    int r = nums.size();
    while (l &lt; r) {
      int m = l + (r - l) / 2;      
      if (nums[m] &gt; target) {
        r = m;
      } else {
        l = m + 1;
      }
    }
    // l points to the first element this is greater than target.
    --l;        
    if (l &lt; 0 || nums[l] != target) return -1;
    return l;
  }
};</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/algorithms/binary-search/leetcode-34-find-first-and-last-position-of-element-in-sorted-array/">花花酱 LeetCode 34. Find First and Last Position of Element in Sorted Array</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/algorithms/binary-search/leetcode-34-find-first-and-last-position-of-element-in-sorted-array/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 LeetCode 1012. Complement of Base 10 Integer</title>
		<link>https://zxi.mytechroad.com/blog/bit/leetcode-1012-complement-of-base-10-integer/</link>
					<comments>https://zxi.mytechroad.com/blog/bit/leetcode-1012-complement-of-base-10-integer/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sun, 17 Mar 2019 06:29:32 +0000</pubDate>
				<category><![CDATA[Bit]]></category>
		<category><![CDATA[bit]]></category>
		<category><![CDATA[easy]]></category>
		<category><![CDATA[O(logn)]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=4974</guid>

					<description><![CDATA[<p>Every non-negative integer&#160;N&#160;has a binary representation.&#160; For example,&#160;5&#160;can be represented as&#160;"101"&#160;in binary,&#160;11&#160;as&#160;"1011"&#160;in binary, and so on.&#160; Note that except for&#160;N = 0, there are no&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/bit/leetcode-1012-complement-of-base-10-integer/">花花酱 LeetCode 1012. Complement of Base 10 Integer</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>Every non-negative integer&nbsp;<code>N</code>&nbsp;has a binary representation.&nbsp; For example,&nbsp;<code>5</code>&nbsp;can be represented as&nbsp;<code>"101"</code>&nbsp;in binary,&nbsp;<code>11</code>&nbsp;as&nbsp;<code>"1011"</code>&nbsp;in binary, and so on.&nbsp; Note that except for&nbsp;<code>N = 0</code>, there are no leading zeroes in any&nbsp;binary representation.</p>



<p>The&nbsp;<em>complement</em>&nbsp;of a binary representation&nbsp;is the number in binary you get when changing every&nbsp;<code>1</code>&nbsp;to a&nbsp;<code>0</code>&nbsp;and&nbsp;<code>0</code>&nbsp;to a&nbsp;<code>1</code>.&nbsp; For example, the complement of&nbsp;<code>"101"</code>&nbsp;in binary is&nbsp;<code>"010"</code>&nbsp;in binary.</p>



<p>For a given number&nbsp;<code>N</code>&nbsp;in base-10, return the complement of it&#8217;s binary representation as a&nbsp;base-10 integer.</p>



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



<pre class="wp-block-preformatted crayon:false"><strong>Input: </strong>5
<strong>Output: </strong>2
<strong>Explanation: </strong>5 is "101" in binary, with complement "010" in binary, which is 2 in base-10.
</pre>



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



<pre class="wp-block-preformatted crayon:false"><strong>Input: </strong>7
<strong>Output: </strong>0
<strong>Explanation: </strong>7 is "111" in binary, with complement "000" in binary, which is 0 in base-10.
</pre>



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



<pre class="wp-block-preformatted crayon:false"><strong>Input: </strong>10
<strong>Output: </strong>5
<strong>Explanation: </strong>10 is "1010" in binary, with complement "0101" in binary, which is 5 in base-10.
</pre>



<p><strong>Note:</strong></p>



<ol><li><code>0 &lt;= N &lt; 10^9</code></li></ol>



<h2><strong>Solution: Bit</strong></h2>



<p>Find the smallest binary number c that is all 1s, (e.g. &#8220;111&#8221;, &#8220;11111&#8221;) that is greater or equal to N.<br>ans = C ^ N or C &#8211; N</p>



<p>Time complexity: O(log(n))<br>Space complexity: O(1)</p>



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

<pre class="crayon-plain-tag">// Author: Huahua, running time: 4 ms, 8 MB
class Solution {
public:
  int bitwiseComplement(int N) {
    int c = 1;
    while (c &lt; N) 
      c = (c &lt;&lt; 1) | 1;
    return N ^ c;    
  }
};</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/bit/leetcode-1012-complement-of-base-10-integer/">花花酱 LeetCode 1012. Complement of Base 10 Integer</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/bit/leetcode-1012-complement-of-base-10-integer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 Segment Tree 线段树 SP14</title>
		<link>https://zxi.mytechroad.com/blog/sp/segment-tree-sp14/</link>
					<comments>https://zxi.mytechroad.com/blog/sp/segment-tree-sp14/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Wed, 30 Jan 2019 16:41:06 +0000</pubDate>
				<category><![CDATA[SP]]></category>
		<category><![CDATA[O(logn)]]></category>
		<category><![CDATA[range sum]]></category>
		<category><![CDATA[segment tree]]></category>
		<category><![CDATA[tree]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=4738</guid>

					<description><![CDATA[<p>Segment tree is a balanced binary tree with O(logn) height given n input segments.Segment tree supports fast range query O(logn + k), and update O(logn).Building&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/sp/segment-tree-sp14/">花花酱 Segment Tree 线段树 SP14</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 width="500" height="375" src="https://www.youtube.com/embed/rYBtViWXYeI?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div></figure>



<p>Segment tree is a balanced binary tree with O(logn) height given n input segments.<br>Segment tree supports fast range query O(logn + k), and update O(logn).<br>Building such a tree takes O(n) time if the input is an array of numbers.</p>



<p>Tree之所以大行其道就是因为其结构和人类组织结构非常接近。就拿公司来说好了，CEO统领全局(root)，下面CTO，CFO等各自管理一个部门，每个部门下面又正好有好两个VP，每个VP下面又有两个director，每个director下面又有2个manager，每个manager下面又有2个底层员工(leaf)，为什么是2？因为我们用二叉树啊~</p>



<p>故事还是要从LeetCode 307. Range Sum Query &#8211; Mutable说起。</p>



<p>题目大意是：给你一个数组，再给你一个范围，让你求这个范围内所有元素的和，其中元素的值是可变的，通过update(index, val)更新。&nbsp;</p>



<p>nums = [1, 3, 5]，<br>sumRange(0, 2) = 1+3+5 = 9<br>update(1, 2) =&gt; [1, 2, 5]<br>sumRange(0, 2) = 1 + 2 + 5 = 7</p>



<p>暴力求解就是扫描一下这个范围。</p>



<p>时间复杂度：Update O(1), Query O(n)。</p>



<p>如果数组元素不变的话（303题），我们可以使用动态规划求出前n个元素的和然后存在sums数组中。i到j所有元素的和等于0~j所有元素的和减去0~(i-1)所有元素的和，即：</p>



<p>sumRange(i, j) := sums[j] &#8211; sums[i &#8211; 1] if i &gt; 0 else sums[j]</p>



<p>这样就可以把query的时间复杂度降低到O(1)。</p>



<p>但是这道题元素的值可变，那么就需要维护sums，虽然可以把query的时间复杂度降低到了O(1)，但update的时间复杂度是O(n)，并没有比暴力求解快。</p>



<p>这个时候就要请出我们今天的主人公Segment Tree了，可以做到</p>



<p>Update: O(logn)，Query: O(logn+k)</p>



<p>其实Segment Tree的思想还是很好理解的，比我们之前讲过的Binary Indexed Tree要容易理解的多（回复&nbsp;<strong>SP3</strong>&nbsp;获取视频），但是代码量又是另外一回事情了&#8230;</p>



<p>回到一开始讲的公司组织结构上面，假设一个公司有200个底层员工，</p>



<p>最原始的信息（元素的值）只掌握在他们工手里，层层上报。每个manager把他所管理的人的元素值求和之后继续上报，直到CEO。CEO知道但仅知道0-199的和。</p>



<p>当你问CEO，5到199的和是多少？他手上只有0-199的和，一下子慌了，赶紧找来CTO，CFO说你们把5到199的和给报上来，CFO一看报表，心中暗喜：还好我负责的这个区间(100~199)已经计算过了，就直接把之前的总和上报了。CTO一看报表，自己负责0-99这个区间，只知道0-99的和，但5-99的和，还是问下面的人吧&#8230; 最后结果再一层层返回给CEO。</p>



<p>说到这里大家应该已经能想象Segment Tree是怎么工作了吧：</p>



<p>每个leaf负责一个元素的值</p>



<p>每个parent负责的范围是他的children所负责的范围的union，并把所有范围内的元素值相加。</p>



<p>同一层的节点没有overlap。</p>



<p>root存储的是所有元素的和。</p>



<p>所以一个SegmentTreeNode需要记录以下信息</p>



<p>start #起始范围<br>end #终止范围<br>mid #拆分点，通常是 (start + end) // 2<br>val #所有子元素的和<br>left #左子树<br>right #右子树</p>



<p>Update: 由于每次只更新一个元素的值，所以CEO知道这个员工是哪个人管的，派发下去就行了，然后把新的结果再返回回来。</p>



<pre class="crayon-plain-tag">def update(root, index, val):
  # 到底层员工了，直接更新
  if root.start == index and root.end == index:
    root.val = val
    return
  # 根据拆分点，更新左子树或右子树
  if val &lt;= root.mid:
    update(root.left, index, val)
  else:
    update(root.right, index, val)
  # 重新计算和
  root.val = root.left?.val + root.right?.val</pre>



<p>T(n) = T(n/2) + 1 =&gt; O(logn)</p>



<p>Query: query的range可以是任意的，就有以下三种情况：</p>



<p>case 1: 这个range正好和我负责的range完全相同。比如sumQuery(CTO, 0, 99)，这个时候CTO直接返回已经求解过的所有下属的和即可。</p>



<p>case 2: 这个range只由我其中一个下属负责。比如sumQuery(CEO, 0, 10)，CEO知道0~10全部由CFO负责，那么他就直接返回sumQuery(CTO, 0, 10)。</p>



<p>case 3: 这个range覆盖了我的两个下属，那么我就需要调用2次。比如sumQuery(CEO, 80, 120)，CEO知道0~99由CTO管，100~199由CFO管，所以他只需要返回：</p>



<p>sumQuery(CTO, 80, 99) + sumQuery(CFO, 100, 120)<br></p>



<p>由此可见sumQuery的时间复杂度是不确定的，运气好时O(1)，运气不好时是O(logn+k)，k是需要访问的节点的数量。 </p>



<p>我做了一个实验，给定N，尝试所有的(i,j)组合，看sumQuery的最坏情况和平均情况，结果如下图：</p>



<figure class="wp-block-image"><img width="600" height="371" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2019/02/query_nodes.png" alt="" class="wp-image-4795" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2019/02/query_nodes.png 600w, https://zxi.mytechroad.com/blog/wp-content/uploads/2019/02/query_nodes-300x186.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></figure>



<p>Query需要访问到的节点数量的worst和average case。Worst case 大约访问 4*logn &#8211; 3 个节点，这个数字远远小于n。和n成对数关系。<br></p>



<p>虽然不像Binary Indexed Tree query是严格的O(logn)，但Segment tree query的worst case增长的非常慢，可以说是对数级别的。当N是2^20的时候，worst case也“只需要”访问77个节点。</p>



<p>最后我们再来讲一下这棵树是怎么创建的，其实方法有很多种，一分为二是比较常规的一种做法。</p>



<p>CEO管200人，那么就找2个人(CTO，CFO各管100人。CTO管100人，再找2个VP各管50人，以此类推，直到manager管2个人，2个人都是底层员工(leaf)，没有人管（双关）。</p>



<pre class="crayon-plain-tag">def buildTree(start, end):
  # 超过范围返回空节点
  if start &amp;gt; end: return None
  boss.start = start
  boss.end = end
  # 如果是叶子节点，记录元素的值
  if start == end: boss.val = nums[start]
  boss.mid = (start + end) // 2
  # 递归构建子树
  boss.left = buildTree(start, mid)
  boss.right = buildTree(mid + 1, end)
  # 求和
  boss.val += boss.left?.val + boss.right?.val
  return boss</pre>



<p>CEO = buildTree(0, 199)</p>



<p>CEO.left # CTO 负责0~99<br>CEO.right # CFO&nbsp;负责100~199</p>



<hr class="wp-block-separator is-style-wide"/>



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



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



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



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



<p>Query: # of nodes visited: Average and worst are both ~O(logn)</p>



<h2>Applications</h2>



<p><a href="https://zxi.mytechroad.com/blog/data-structure/307-range-sum-query-mutable/">LeetCode&nbsp;307&nbsp;Range&nbsp;Sum&nbsp;Query&nbsp;&#8211;&nbsp;Mutable</a></p>



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

<pre class="crayon-plain-tag">// Author: Huahua, running time: 24 ms
class SegmentTreeNode {
public:
  SegmentTreeNode(int start, int end, int sum,
                  SegmentTreeNode* left = nullptr,
                  SegmentTreeNode* right = nullptr): 
    start(start),
    end(end),
    sum(sum),
    left(left),
    right(right){}      
  SegmentTreeNode(const SegmentTreeNode&amp;) = delete;
  SegmentTreeNode&amp; operator=(const SegmentTreeNode&amp;) = delete;
  ~SegmentTreeNode() {
    delete left;
    delete right;
    left = right = nullptr;
  }
  
  int start;
  int end;
  int sum;
  SegmentTreeNode* left;
  SegmentTreeNode* right;
};

class NumArray {
public:
  NumArray(vector&lt;int&gt; nums) {
    nums_.swap(nums);
    if (!nums_.empty())
      root_.reset(buildTree(0, nums_.size() - 1));
  }

  void update(int i, int val) {
    updateTree(root_.get(), i, val);
  }

  int sumRange(int i, int j) {
    return sumRange(root_.get(), i, j);
  }
private:
  vector&lt;int&gt; nums_;
  std::unique_ptr&lt;SegmentTreeNode&gt; root_;
  
  SegmentTreeNode* buildTree(int start, int end) {  
    if (start == end) {      
      return new SegmentTreeNode(start, end, nums_[start]);
    }
    int mid = start + (end - start) / 2;
    auto left = buildTree(start, mid);
    auto right = buildTree(mid + 1, end);
    auto node = new SegmentTreeNode(start, end, left-&gt;sum + right-&gt;sum, left, right);    
    return node;
  }
  
  void updateTree(SegmentTreeNode* root, int i, int val) {
    if (root-&gt;start == i &amp;&amp; root-&gt;end == i) {
      root-&gt;sum = val;
      return;
    }
    int mid = root-&gt;start + (root-&gt;end - root-&gt;start) / 2;
    if (i &lt;= mid) {
      updateTree(root-&gt;left, i, val);
    } else {      
      updateTree(root-&gt;right, i, val);
    }
    root-&gt;sum = root-&gt;left-&gt;sum + root-&gt;right-&gt;sum;
  }
  
  int sumRange(SegmentTreeNode* root, int i, int j) {    
    if (i == root-&gt;start &amp;&amp; j == root-&gt;end) {
      return root-&gt;sum;
    }
    int mid = root-&gt;start + (root-&gt;end - root-&gt;start) / 2;
    if (j &lt;= mid) {
      return sumRange(root-&gt;left, i, j);
    } else if (i &gt; mid) {
      return sumRange(root-&gt;right, i, j);
    } else {
      return sumRange(root-&gt;left, i, mid) + sumRange(root-&gt;right, mid + 1, j);
    }
  }
};</pre>

</div><h2 class="tabtitle">Python3</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag"># Author: Huahua, running time: 176 ms
class SegmentTreeNode:
  def __init__(self, start, end, val, left=None, right=None):
    self.start = start
    self.end = end
    self.mid = start + (end - start) // 2
    self.val = val
    self.left = left
    self.right = right

class NumArray:
  def __init__(self, nums):
    self.nums = nums
    if self.nums:
      self.root = self._buildTree(0, len(nums) - 1)

  def update(self, i, val):      
    self._updateTree(self.root, i, val)

  def sumRange(self, i, j):
    return self._sumRange(self.root, i, j)
    
  
  def _buildTree(self, start, end):
    if start == end: return SegmentTreeNode(start, end, self.nums[start])
    mid = start + (end - start) // 2
    left = self._buildTree(start, mid)
    right = self._buildTree(mid + 1, end)
    return SegmentTreeNode(start, end, left.val + right.val, left, right)
  
  def _updateTree(self, root, i, val):
    if root.start == i and root.end == i:
      root.val = val
      return    
    if i &lt;= root.mid:
      self._updateTree(root.left, i, val)
    else:
      self._updateTree(root.right, i, val)
    root.val = root.left.val + root.right.val
  
  def _sumRange(self, root, i, j):
    if root.start == i and root.end == j:
      return root.val
    if j &lt;= root.mid:
      return self._sumRange(root.left, i, j)
    elif i &gt; root.mid:
      return self._sumRange(root.right, i, j)
    else:
      return self._sumRange(root.left, i, root.mid) + self._sumRange(root.right, root.mid + 1, j)</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/sp/segment-tree-sp14/">花花酱 Segment Tree 线段树 SP14</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/sp/segment-tree-sp14/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
