-
Notifications
You must be signed in to change notification settings - Fork 33
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
Conversation
Signed-off-by: Amisha Sahu <[email protected]>
There was a problem hiding this 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()); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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++) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Thank You @Tahanima. |
Hey, @Tahanima. |
This resolves #17 |
There was a problem hiding this 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! 🙌
Thank you so much. Happy to contribute. 😀 |
Problem link: