Skip to content

Commit

Permalink
Sync LeetCode submission - Find the Duplicate Number (cpp)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheikh-arman committed Sep 19, 2023
1 parent aad4a8d commit bebd9cc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions AC-Submissions/problems/find_the_duplicate_number/solution.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution {
public:
int findDuplicate(vector<int>& nums) {
int ind = 0;
sort(nums.begin(),nums.end());
for(int i = 0; i < nums.size() - 1; i++)
{
if(nums[i] == nums[i+1])
{
ind = nums[i];
break;
}
}
return ind;
}
};

0 comments on commit bebd9cc

Please sign in to comment.