zoukankan      html  css  js  c++  java
  • [Swift]LeetCode1233. 删除子文件夹 | Remove Sub-Folders from the Filesystem

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
    ➤微信公众号:山青咏芝(let_us_code)
    ➤博主域名:https://www.zengqiang.org
    ➤GitHub地址:https://github.com/strengthen/LeetCode
    ➤原文地址:https://www.cnblogs.com/strengthen/p/11712798.html
    ➤如果链接不是山青咏芝的博客园地址,则可能是爬取作者的文章。
    ➤原文已修改更新!强烈建议点击原文地址阅读!支持作者!支持原创!
    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

    Given a list of folders, remove all sub-folders in those folders and return in any order the folders after removing.

    If a folder[i] is located within another folder[j], it is called a sub-folder of it.

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

    Example 1:

    Input: folder = ["/a","/a/b","/c/d","/c/d/e","/c/f"]
    Output: ["/a","/c/d","/c/f"]
    Explanation: Folders "/a/b/" is a subfolder of "/a" and "/c/d/e" is inside of folder "/c/d" in our filesystem.
    Example 2:

    Input: folder = ["/a","/a/b/c","/a/b/d"]
    Output: ["/a"]
    Explanation: Folders "/a/b/c" and "/a/b/d/" will be removed because they are subfolders of "/a".
    Example 3:

    Input: folder = ["/a/b/c","/a/b/d","/a/b/ca"]
    Output: ["/a/b/c","/a/b/ca","/a/b/d"]

    Constraints:

    1 <= folder.length <= 4 * 10^4
    2 <= folder[i].length <= 100
    folder[i] contains only lowercase letters and '/'
    folder[i] always starts with character '/'
    Each folder name is unique.


    你是一位系统管理员,手里有一份文件夹列表 folder,你的任务是要删除该列表中的所有 子文件夹,并以 任意顺序 返回剩下的文件夹。

    我们这样定义「子文件夹」:

    如果文件夹 folder[i] 位于另一个文件夹 folder[j] 下,那么 folder[i] 就是 folder[j] 的子文件夹。
    文件夹的「路径」是由一个或多个按以下格式串联形成的字符串:

    / 后跟一个或者多个小写英文字母。
    例如,/leetcode 和 /leetcode/problems 都是有效的路径,而空字符串和 / 不是。

    示例 1:

    输入:folder = ["/a","/a/b","/c/d","/c/d/e","/c/f"]
    输出:["/a","/c/d","/c/f"]
    解释:"/a/b/" 是 "/a" 的子文件夹,而 "/c/d/e" 是 "/c/d" 的子文件夹。
    示例 2:

    输入:folder = ["/a","/a/b/c","/a/b/d"]
    输出:["/a"]
    解释:文件夹 "/a/b/c" 和 "/a/b/d/" 都会被删除,因为它们都是 "/a" 的子文件夹。
    示例 3:

    输入:folder = ["/a/b/c","/a/b/d","/a/b/ca"]
    输出:["/a/b/c","/a/b/ca","/a/b/d"]
     

    提示:

    1 <= folder.length <= 4 * 10^4
    2 <= folder[i].length <= 100
    folder[i] 只包含小写字母和 /
    folder[i] 总是以字符 / 起始
    每个文件夹名都是唯一的

  • 相关阅读:
    Python多线程之死锁
    Python多线程之间同步总结
    C语言动态数组
    Python标准库 -- UUID模块(生成唯一标识)
    东南亚 SAP 实施 马来西亚税收在SAP的设计和实现
    odoo:开源 ERP/CRM 入门与实践 -- 上海嘉冰信息技术公司提供咨询服务
    SAP FICO 凭证导入接口 数据xml格式
    SAP HANA S4 FI TABLE表结构
    CFA一级知识点总结
    汽车行业与 Telematics
  • 原文地址:https://www.cnblogs.com/strengthen/p/11712798.html
Copyright © 2011-2022 走看看