Skip to content

Commit

Permalink
Time: 109 ms (39.26%), Space: 64.8 MB (22.07%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakkumar9546 committed Feb 13, 2024
1 parent 0aa4f34 commit 64a24c5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 0287-find-the-duplicate-number/0287-find-the-duplicate-number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
public:
int findDuplicate(vector<int>& nums) {
long long n = nums.size();
sort(nums.begin(), nums.end());
for (int i = 0; i < n; i++) {
if (nums[i] == nums[i + 1]) {
return nums[i];
}
}
return {};
}
};

0 comments on commit 64a24c5

Please sign in to comment.