Skip to content

Docs: Added Solutions to Leetcode 609 #1411

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 2 commits into from
Jun 16, 2024

Conversation

shreyash3087
Copy link
Contributor

Related Issue

Closes #1376

Description

This PR adds the solution to leetcode problem 609 - (Find Duplicate File in System)

Type of PR

  • Bug fix
  • Feature enhancement
  • Documentation update
  • Security enhancement
  • Other (specify): _______________

Screenshots / Videos (if applicable)

screencapture-localhost-3000-dsa-solutions-lc-solutions-0600-0699-find-duplicate-file-in-system-2024-06-16-18_26_26

Checklist

  • I have performed a self-review of my code.
  • I have read and followed the Contribution Guidelines.
  • I have tested the changes thoroughly before submitting this pull request.
  • I have provided relevant issue numbers, screenshots, and videos after making the changes.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have followed the code style guidelines of this project.
  • I have checked for any existing open issues that my pull request may address.
  • I have ensured that my changes do not break any existing functionality.
  • Each contributor is allowed to create a maximum of 4 issues per day. This helps us manage and address issues efficiently.
  • I have read the resources for guidance listed below.
  • I have followed security best practices in my code changes.

Additional Context

N/A

Copy link
Contributor

deepsource-io bot commented Jun 16, 2024

Here's the code health analysis summary for commits 6d71973..a08b8bb. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Great job, @shreyash3087! 🎉 Thank you for submitting your pull request to CodeHarborHub. We appreciate your contribution and enthusiasm! Our team will review it soon. If you have any questions or need further assistance, feel free to reach out. Thanks for contributing!

@ajay-dhangar ajay-dhangar added documentation Improvements or additions to documentation GSSOC'24 GirlScript Summer of Code | Contributor level1 GirlScript Summer of Code | Contributor's Levels gssoc GirlScript Summer of Code | Contributor labels Jun 16, 2024
Copy link
Member

@ajay-dhangar ajay-dhangar left a comment

Choose a reason for hiding this comment

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

update your code based on suggestions


### Constraints

- $1 <= paths.length <= 2 * 10^4$
Copy link
Member

Choose a reason for hiding this comment

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

basic practice

$1 <= paths.length <= 2 * 10^4$

Good Practice

$1 \leq \text{paths.length} \leq  2 \times 10^4$

### Constraints

- $1 <= paths.length <= 2 * 10^4$
- $1 <= paths[i].length <= 3000$
Copy link
Member

Choose a reason for hiding this comment

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

also, replace - $1 <= paths[i].length <= 3000$ to best or Good practice


## Solution for Find Duplicate File in System

### Approach #1 Brute Force [Time Limit Exceeded]
Copy link
Member

Choose a reason for hiding this comment

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

replace #1 to 1


> **Reason**: Size of lists res and list can grow upto n∗x.

### Approach #2 Using HashMap
Copy link
Member

Choose a reason for hiding this comment

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

replace #2 to 2


> **Reason**: Creation of list will take O(n∗x), where n is the number of directories and x is the average string length. Every file is compared with every other file. Let f files are there with average size of s, then files comparision will take O(f2∗s), equals can take O(s). Here, Worst case will be when all files are unique.

### Space Complexity: $O(n*x)$
Copy link
Member

Choose a reason for hiding this comment

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

replace $O(n*x)$ to $O(n \times x)$


## Complexity Analysis

### Time Complexity: $O(n*x + f^2 * s)$
Copy link
Member

Choose a reason for hiding this comment

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

replace $O(n*x + f^2 * s)$ to $O(n \times x + f^2 \times s)$


> **Reason**: n strings of average length x is parsed.

### Space Complexity: $O(n*x)$
Copy link
Member

Choose a reason for hiding this comment

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

also, update $O(n*x)$ to best practice

@shreyash3087
Copy link
Contributor Author

@ajay-dhangar Done

Copy link
Member

@ajay-dhangar ajay-dhangar left a comment

Choose a reason for hiding this comment

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

Done

@ajay-dhangar ajay-dhangar merged commit 6ea2885 into codeharborhub:main Jun 16, 2024
4 checks passed
@sanjay-kv sanjay-kv removed the level1 GirlScript Summer of Code | Contributor's Levels label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation gssoc GirlScript Summer of Code | Contributor GSSOC'24 GirlScript Summer of Code | Contributor
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Leetcode Problem 609 - (Find Duplicate File in System-Medium)
3 participants