Skip to content

Solution to LeetCode problem: 287 #38

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 4 commits into from
Jul 31, 2021
Merged

Solution to LeetCode problem: 287 #38

merged 4 commits into from
Jul 31, 2021

Conversation

Amisha328
Copy link
Contributor

@Amisha328
Copy link
Contributor Author

Hey @Tahanima,
Please check PR #38 and let me know if any further changes are required.

Copy link
Owner

@Tahanima Tahanima left a comment

Choose a reason for hiding this comment

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

Hi @Amisha328
Please resolve the requested changes.

class Solution {
public:
int findDuplicate(vector<int>& nums) {
sort(nums.begin(),nums.end());
Copy link
Owner

Choose a reason for hiding this comment

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

Change this line to this:

sort(nums.begin(), nums.end());

public:
int findDuplicate(vector<int>& nums) {
sort(nums.begin(),nums.end());
int n =nums.size();
Copy link
Owner

Choose a reason for hiding this comment

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

Change this line to this:

int n = nums.size();

int findDuplicate(vector<int>& nums) {
sort(nums.begin(),nums.end());
int n =nums.size();
for(int i = 0;i<n-1;i++)
Copy link
Owner

Choose a reason for hiding this comment

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

Change this line to this:

for (int i = 0; i < n-1; i++)

}
};

// Time Complexity: O(n)
Copy link
Owner

Choose a reason for hiding this comment

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

Your solution's time complexity is O(nlogn) because of calling the sort function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, yes, thank you. I will do make changes.

@Amisha328
Copy link
Contributor Author

Thank You @Tahanima.
I will make all the suggested changes ASAP.

@Amisha328
Copy link
Contributor Author

Hey, @Tahanima.
I have made the suggested changes. Please let me know if any further changes are required.

@Tahanima
Copy link
Owner

This resolves #17

Copy link
Owner

@Tahanima Tahanima left a comment

Choose a reason for hiding this comment

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

Great work! 🔥 Thank you so much for your contribution! 😀 and welcome to LeetCode Solution Curation as a Contributor

Cheers! 🙌

@Tahanima Tahanima merged commit 4ec24ba into Tahanima:main Jul 31, 2021
@Amisha328
Copy link
Contributor Author

Great work! 🔥 Thank you so much for your contribution! 😀 and welcome to LeetCode Solution Curation as a Contributor

Cheers! 🙌

Thank you so much. Happy to contribute. 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants