<?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>hsahtable Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/hsahtable/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/tag/hsahtable/</link>
	<description></description>
	<lastBuildDate>Tue, 22 Oct 2019 05:38:14 +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>hsahtable Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/tag/hsahtable/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>花花酱 LeetCode 1233. Remove Sub-Folders from the Filesystem</title>
		<link>https://zxi.mytechroad.com/blog/hashtable/leetcode-1233-remove-sub-folders-from-the-filesystem/</link>
					<comments>https://zxi.mytechroad.com/blog/hashtable/leetcode-1233-remove-sub-folders-from-the-filesystem/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Tue, 22 Oct 2019 05:38:07 +0000</pubDate>
				<category><![CDATA[Hashtable]]></category>
		<category><![CDATA[hsahtable]]></category>
		<category><![CDATA[medium]]></category>
		<category><![CDATA[path]]></category>
		<category><![CDATA[string]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=5776</guid>

					<description><![CDATA[<p>Given a list of folders, remove all sub-folders in those folders and return in&#160;any order&#160;the folders after removing. If a&#160;folder[i]&#160;is located within&#160;another&#160;folder[j], it is called&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/hashtable/leetcode-1233-remove-sub-folders-from-the-filesystem/">花花酱 LeetCode 1233. Remove Sub-Folders from the Filesystem</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 a list of folders, remove all sub-folders in those folders and return in&nbsp;<strong>any order</strong>&nbsp;the folders after removing.</p>



<p>If a&nbsp;<code>folder[i]</code>&nbsp;is located within&nbsp;another&nbsp;<code>folder[j]</code>, it is called a&nbsp;sub-folder&nbsp;of it.</p>



<p>The format of a path is&nbsp;one or more concatenated strings of the form:&nbsp;<code>/</code>&nbsp;followed by one or more lowercase English letters. For example,&nbsp;<code>/leetcode</code>&nbsp;and&nbsp;<code>/leetcode/problems</code>&nbsp;are valid paths while an empty string and&nbsp;<code>/</code>&nbsp;are not.</p>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> folder = ["/a","/a/b","/c/d","/c/d/e","/c/f"]
<strong>Output:</strong> ["/a","/c/d","/c/f"]
<strong>Explanation:</strong> Folders "/a/b/" is a subfolder of "/a" and "/c/d/e" is inside of folder "/c/d" in our filesystem.
</pre>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> folder = ["/a","/a/b/c","/a/b/d"]
<strong>Output:</strong> ["/a"]
<strong>Explanation:</strong> Folders "/a/b/c" and "/a/b/d/" will be removed because they are subfolders of "/a".
</pre>



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



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> folder = ["/a/b/c","/a/b/ca","/a/b/d"]
<strong>Output:</strong> ["/a/b/c","/a/b/ca","/a/b/d"]
</pre>



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



<ul><li><code>1 &lt;= folder.length&nbsp;&lt;= 4 * 10^4</code></li><li><code>2 &lt;= folder[i].length &lt;= 100</code></li><li><code>folder[i]</code>&nbsp;contains only&nbsp;lowercase letters and &#8216;/&#8217;</li><li><code>folder[i]</code>&nbsp;always starts with character &#8216;/&#8217;</li><li>Each folder name is unique.</li></ul>



<h2><strong>Solution: HashTable</strong></h2>



<p>Time complexity: O(n*L)<br>Space complexity: O(n*L)</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;string&gt; removeSubfolders(vector&lt;string&gt;&amp; folder) {
    unordered_set&lt;string&gt; s(begin(folder), end(folder));
    vector&lt;string&gt; ans;
    for (const auto&amp; cur : folder) {
      string f = cur;
      bool valid = true;
      while (!f.empty() &amp;&amp; valid) {
        while (f.back() != '/') f.pop_back();
        f.pop_back();
        if (s.count(f)) valid = false;
      }
      if (valid) ans.push_back(cur);
    }
    return ans;
  }
};</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/hashtable/leetcode-1233-remove-sub-folders-from-the-filesystem/">花花酱 LeetCode 1233. Remove Sub-Folders from the Filesystem</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-1233-remove-sub-folders-from-the-filesystem/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
