代码拉取完成,页面将自动刷新
同步操作将从 小墨/力扣题库(完整版) 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<p>Given a list <code>paths</code> of directory info, including the directory path, and all the files with contents in this directory, return <em>all the duplicate files in the file system in terms of their paths</em>. You may return the answer in <strong>any order</strong>.</p>
<p>A group of duplicate files consists of at least two files that have the same content.</p>
<p>A single directory info string in the input list has the following format:</p>
<ul>
<li><code>"root/d1/d2/.../dm f1.txt(f1_content) f2.txt(f2_content) ... fn.txt(fn_content)"</code></li>
</ul>
<p>It means there are <code>n</code> files <code>(f1.txt, f2.txt ... fn.txt)</code> with content <code>(f1_content, f2_content ... fn_content)</code> respectively in the directory "<code>root/d1/d2/.../dm"</code>. Note that <code>n >= 1</code> and <code>m >= 0</code>. If <code>m = 0</code>, it means the directory is just the root directory.</p>
<p>The output is a list of groups of duplicate file paths. For each group, it contains all the file paths of the files that have the same content. A file path is a string that has the following format:</p>
<ul>
<li><code>"directory_path/file_name.txt"</code></li>
</ul>
<p> </p>
<p><strong>Example 1:</strong></p>
<pre><strong>Input:</strong> paths = ["root/a 1.txt(abcd) 2.txt(efgh)","root/c 3.txt(abcd)","root/c/d 4.txt(efgh)","root 4.txt(efgh)"]
<strong>Output:</strong> [["root/a/2.txt","root/c/d/4.txt","root/4.txt"],["root/a/1.txt","root/c/3.txt"]]
</pre><p><strong>Example 2:</strong></p>
<pre><strong>Input:</strong> paths = ["root/a 1.txt(abcd) 2.txt(efgh)","root/c 3.txt(abcd)","root/c/d 4.txt(efgh)"]
<strong>Output:</strong> [["root/a/2.txt","root/c/d/4.txt"],["root/a/1.txt","root/c/3.txt"]]
</pre>
<p> </p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= paths.length <= 2 * 10<sup>4</sup></code></li>
<li><code>1 <= paths[i].length <= 3000</code></li>
<li><code>1 <= sum(paths[i].length) <= 5 * 10<sup>5</sup></code></li>
<li><code>paths[i]</code> consist of English letters, digits, <code>'/'</code>, <code>'.'</code>, <code>'('</code>, <code>')'</code>, and <code>' '</code>.</li>
<li>You may assume no files or directories share the same name in the same directory.</li>
<li>You may assume each given directory info represents a unique directory. A single blank space separates the directory path and file info.</li>
</ul>
<p> </p>
<p><strong>Follow up:</strong></p>
<ul>
<li>Imagine you are given a real file system, how will you search files? DFS or BFS?</li>
<li>If the file content is very large (GB level), how will you modify your solution?</li>
<li>If you can only read the file by 1kb each time, how will you modify your solution?</li>
<li>What is the time complexity of your modified solution? What is the most time-consuming part and memory-consuming part of it? How to optimize?</li>
<li>How to make sure the duplicated files you find are not false positive?</li>
</ul>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。