Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Arrays & Strings/Duplicates checking cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
public:
bool containsDuplicate(vector<int>& nums) {
sort(nums.begin(), nums.end()); // O(n log n)
for (int i = 1; i < nums.size(); ++i) {
if (nums[i] == nums[i - 1]) {
return true;
}
}
return false;
}
};

Comment on lines +1 to +13
Copy link
Member

Choose a reason for hiding this comment

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

12 changes: 12 additions & 0 deletions Hashing/Contains_Duplicate/contains_duplicate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution {
public:
bool containsDuplicate(vector<int>& nums) {
sort(nums.begin(), nums.end()); // O(n log n)
for (int i = 1; i < nums.size(); ++i) {
if (nums[i] == nums[i - 1]) {
return true;
}
}
return false;
}
};
Comment on lines +1 to +12
Copy link
Member

Choose a reason for hiding this comment

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

Same as the solution above. And not following convention. It should be 1 Solution at a time. Follow the Folder structure.