Skip to content

feat: add solution for deleting duplicate folders in a file system #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 20, 2025

Conversation

Speccy-Rom
Copy link
Owner

@Speccy-Rom Speccy-Rom commented Jul 20, 2025

Summary by Sourcery

Add Trie-based implementations for deleting duplicate folders in Python3 and Go and update README documentation to include the new solutions.

New Features:

  • Add Python3 solution implementing Trie-based duplicate folder deletion
  • Add Go solution implementing Trie-based duplicate folder deletion
  • Introduce standalone Solution.py and Solution.go modules for the problem

Documentation:

  • Update English and default README files to include Python3 and Go code examples for the delete duplicate folders problem
  • Fix minor formatting in the problem explanation section

@Speccy-Rom Speccy-Rom self-assigned this Jul 20, 2025
@Speccy-Rom Speccy-Rom added the good first issue Good for newcomers label Jul 20, 2025
Copy link

sourcery-ai bot commented Jul 20, 2025

Reviewer's Guide

Adds a trie-based algorithm that builds a folder tree from input paths, serializes each subtree to detect duplicates, marks duplicate nodes for deletion, and collects remaining paths; implementations are provided in Python and Go and documentation updated accordingly.

Class diagram for TrieNode and Solution classes (Python)

classDiagram
    class TrieNode {
        +dict children
        +str key
        +bool deleted
    }
    class Solution {
        +deleteDuplicateFolder(paths: List[List[str]]) List[List[str]]
    }
    Solution --> TrieNode : uses
Loading

Class diagram for TrieNode struct and deleteDuplicateFolder function (Go)

classDiagram
    class TrieNode {
        +map[string]*TrieNode children
        +string key
        +bool deleted
    }
    class deleteDuplicateFolder {
        +deleteDuplicateFolder(paths [][]string) [][]string
    }
    deleteDuplicateFolder --> TrieNode : uses
Loading

Flow diagram for duplicate folder deletion process

flowchart TD
    A[Build Trie from paths] --> B[DFS serialize subtrees]
    B --> C[Mark duplicate subtrees as deleted]
    C --> D[Collect remaining paths]
    D --> E[Return result]
Loading

File-Level Changes

Change Details Files
Introduce trie-based detection and removal of duplicate folders
  • Define TrieNode with children, key, and deletion flag
  • Populate trie from input paths
  • Perform DFS to serialize subtrees and mark duplicates
  • Collect non-deleted folder paths via traversal
solution/1900-1999/1948.Delete Duplicate Folders in System/Solution.py
solution/1900-1999/1948.Delete Duplicate Folders in System/Solution.go
Update documentation to include code samples and fix formatting
  • Insert Python and Go solution code blocks into README_EN.md
  • Mirror code additions in README.md
  • Remove trailing space in README_EN.md explanation
solution/1900-1999/1948.Delete Duplicate Folders in System/README_EN.md
solution/1900-1999/1948.Delete Duplicate Folders in System/README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Speccy-Rom Speccy-Rom merged commit 593e789 into main Jul 20, 2025
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Speccy-Rom - I've reviewed your changes - here's some feedback:

  • Remove the unused key field from both Python and Go TrieNode definitions to simplify the data structure.
  • Align the duplicate-marking logic between the Python (list-based) and Go (single-instance map) implementations so they handle multiple identical subtrees in the same way.
  • Reduce duplicated code in README_EN.md and README.md by consolidating the examples into a single snippet or referencing the solution files directly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Remove the unused `key` field from both Python and Go TrieNode definitions to simplify the data structure.
- Align the duplicate-marking logic between the Python (list-based) and Go (single-instance map) implementations so they handle multiple identical subtrees in the same way.
- Reduce duplicated code in README_EN.md and README.md by consolidating the examples into a single snippet or referencing the solution files directly.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Speccy-Rom Speccy-Rom deleted the solution-of-this-Leetcode-Problem-1233 branch July 20, 2025 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant