Skip to content

Commit

Permalink
Time: 7 ms, Memory: 10 MB - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
ArbitCode committed Dec 17, 2022
1 parent ecf6809 commit 89357b2
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution {
public:
int getExistIndex(vector<int>& arr, int element){
for(int i = 0; i < arr.size(); i++){
if(arr[i] == element) return i;
}
return -1;
}
bool checkIfExist(vector<int>& arr) {
for(int i = 0; i < arr.size(); i++){
int j = getExistIndex(arr, arr[i]*2);
if(i!=j && j >= 0) return true;
}
return false;

}
};

0 comments on commit 89357b2

Please sign in to comment.