<?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>reminder Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/reminder/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/tag/reminder/</link>
	<description></description>
	<lastBuildDate>Sat, 14 Jul 2018 16:43:11 +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>reminder Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/tag/reminder/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>花花酱 LeetCode 523. Continuous Subarray Sum</title>
		<link>https://zxi.mytechroad.com/blog/hashtable/leetcode-523-continuous-subarray-sum/</link>
					<comments>https://zxi.mytechroad.com/blog/hashtable/leetcode-523-continuous-subarray-sum/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sat, 14 Jul 2018 14:59:05 +0000</pubDate>
				<category><![CDATA[Hashtable]]></category>
		<category><![CDATA[k]]></category>
		<category><![CDATA[medium]]></category>
		<category><![CDATA[prefix sum]]></category>
		<category><![CDATA[reminder]]></category>
		<category><![CDATA[subarray]]></category>
		<category><![CDATA[sum]]></category>
		<guid isPermaLink="false">http://zxi.mytechroad.com/blog/?p=3127</guid>

					<description><![CDATA[<p>Problem Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/hashtable/leetcode-523-continuous-subarray-sum/">花花酱 LeetCode 523. Continuous Subarray Sum</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1><strong>Problem</strong></h1>
<p>Given a list of <b>non-negative</b> numbers and a target <b>integer</b> k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the multiple of <b>k</b>, that is, sums up to n*k where n is also an <b>integer</b>.</p>
<p><b>Example 1:</b></p>
<pre class="crayon:false"><b>Input:</b> [23, 2, 4, 6, 7],  k=6
<b>Output:</b> True
<b>Explanation:</b> Because [2, 4] is a continuous subarray of size 2 and sums up to 6.
</pre>
<p><b>Example 2:</b></p>
<pre class="crayon:false"><b>Input:</b> [23, 2, 6, 4, 7],  k=6
<b>Output:</b> True
<b>Explanation:</b> Because [23, 2, 6, 4, 7] is an continuous subarray of size 5 and sums up to 42.
</pre>
<p><b>Note:</b></p>
<ol>
<li>The length of the array won&#8217;t exceed 10,000.</li>
<li>You may assume the sum of all the numbers is in the range of a signed 32-bit integer.</li>
</ol>
<h1><strong>Special case: </strong></h1>
<p>nums = [0,0], k = 0, return = True</p>
<h1><strong>Solution: Prefix Sum Reminder</strong></h1>
<p>Time complexity: O(n)</p>
<p>Space complexity: O(min(n, k))</p><pre class="crayon-plain-tag">// Author: Huahua
// Running time: 16 ms (&lt;99.62%)
class Solution {
public:
  bool checkSubarraySum(vector&lt;int&gt;&amp; nums, int k) {    
    unordered_map&lt;int, int&gt; m; // sum % k -&gt; first index
    m[0] = -1;
    int sum = 0;
    for (int i = 0; i &lt; nums.size(); ++i) {
      sum += nums[i];
      if (k != 0) sum %= k;      
      if (m.count(sum)) {
        if (i - m.at(sum) &gt; 1) return true;
      } else {
        m[sum] = i;
      }
    }
    return false;
  }
};</pre><p></p>
<h1><strong>Related Problems</strong></h1>
<ul>
<li><a href="http://zxi.mytechroad.com/blog/hashtable/leetcode-560-subarray-sum-equals-k/">花花酱 LeetCode 560. Subarray Sum Equals K</a></li>
<li><a href="http://zxi.mytechroad.com/blog/hashtable/leetcode-525-contiguous-array/">花花酱 LeetCode 525. Contiguous Array</a></li>
</ul>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/hashtable/leetcode-523-continuous-subarray-sum/">花花酱 LeetCode 523. Continuous Subarray Sum</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/hashtable/leetcode-523-continuous-subarray-sum/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 LeetCode 728. Self Dividing Numbers</title>
		<link>https://zxi.mytechroad.com/blog/math/leetcode-728-self-dividing-numbers/</link>
					<comments>https://zxi.mytechroad.com/blog/math/leetcode-728-self-dividing-numbers/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sun, 19 Nov 2017 16:13:34 +0000</pubDate>
				<category><![CDATA[Easy]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[digit]]></category>
		<category><![CDATA[mod]]></category>
		<category><![CDATA[reminder]]></category>
		<guid isPermaLink="false">http://zxi.mytechroad.com/blog/?p=845</guid>

					<description><![CDATA[<p>Problem: A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/math/leetcode-728-self-dividing-numbers/">花花酱 LeetCode 728. Self Dividing Numbers</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/Px8TABDC7ag?feature=oembed" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe></p>
<p><strong>Problem:</strong></p>
<p>A <i>self-dividing number</i> is a number that is divisible by every digit it contains.</p>
<p>For example, 128 is a self-dividing number because <code>128 % 1 == 0</code>, <code>128 % 2 == 0</code>, and <code>128 % 8 == 0</code>.</p>
<p>Also, a self-dividing number is not allowed to contain the digit zero.</p>
<p>Given a lower and upper number bound, output a list of every possible self dividing number, including the bounds if possible.</p>
<p><b>Example 1:</b></p><pre class="crayon-plain-tag">Input: 
left = 1, right = 22
Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]</pre><p><b>Note:</b></p>
<ul>
<li>The boundaries of each input argument are <code>1 &lt;= left &lt;= right &lt;= 10000</code>.</li>
</ul>
<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><br />
<strong>Idea:</strong></p>
<p><a href="http://zxi.mytechroad.com/blog/wp-content/uploads/2017/11/728-ep111-1.png"><img class="alignnone size-full wp-image-851" src="http://zxi.mytechroad.com/blog/wp-content/uploads/2017/11/728-ep111-1.png" alt="" width="960" height="540" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2017/11/728-ep111-1.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2017/11/728-ep111-1-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2017/11/728-ep111-1-768x432.png 768w, https://zxi.mytechroad.com/blog/wp-content/uploads/2017/11/728-ep111-1-624x351.png 624w" sizes="(max-width: 960px) 100vw, 960px" /></a></p>
<p>Brute Force</p>
<p>Time Complexity: O(n)</p>
<p>Space Complexity: O(1)</p>
<p>&nbsp;</p>
<p><strong>Solution:</strong></p>
<p>C++</p><pre class="crayon-plain-tag">// Author: Huahua
// Runtime: 3 ms
class Solution {
public:
    vector&lt;int&gt; selfDividingNumbers(int left, int right) {
        vector&lt;int&gt; ans;
        for (int n = left; n &lt;= right; ++n) {
            int t = n;
            bool valid = true;
            while (t &amp;&amp; valid) {
                const int r = t % 10;
                if (r == 0 || n % r)
                    valid = false;
                t /= 10;
            }
            if (valid) ans.push_back(n);
        }
        return ans;
    }
};</pre><p>String</p><pre class="crayon-plain-tag">// Author: Huahua
// Runtime: 6 ms
class Solution {
public:
    vector&lt;int&gt; selfDividingNumbers(int left, int right) {
        vector&lt;int&gt; ans;
        for (int n = left; n &lt;= right; ++n) {
            const string t = std::to_string(n);
            bool valid = true;
            for (const char c : t) {
                if (c == '0' || n % (c - '0')) {
                    valid = false;
                    break;
                }
            }
            if (valid) ans.push_back(n);
        }
        return ans;
    }
};</pre><p>&nbsp;</p>
<p><strong>Related Problems:</strong></p>
<ul>
<li><a href="http://zxi.mytechroad.com/blog/math/leetcode-611-valid-triangle-number/">[解题报告] LeetCode 611. Valid Triangle Number</a></li>
</ul>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/math/leetcode-728-self-dividing-numbers/">花花酱 LeetCode 728. Self Dividing Numbers</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-728-self-dividing-numbers/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
