Skip to content
Merged
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
28 changes: 28 additions & 0 deletions Beginners_Contest/Contest_44/Even_Sum_Array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include<bits/stdc++.h>
using namespace std;

int makeEvenSum(int n, vector<int> &a) {
// Write your code here.
int odd = 0;
int even = 0;
for(int i=0; i<n; i++){
if(a[i]%2 == 0){
even++;
}
else{
odd++;
}
}
if(odd%2!=0 && even==0){
return 0;
}
else{
return 1;
}
}

int main(){
int n = 4;
vector<int> arr = {1, 5, 5, 10};
cout << makeEvenSum(n, arr) << endl;
}
26 changes: 26 additions & 0 deletions Beginners_Contest/Number_of_Good_Indices.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include<bits/stdc++.h>
using namespace std;

int numberOfGoodIndices(int n, vector<int>& a) {
// Write Your Code Here.
int count = 0;
int temp = 0;
for(int i=0; i<n; i++){
temp = 0;
for(int j=0; j<n; j++){
if(i!=j && a[i] % a[j] == 0){
temp++;
}
}
if(temp >= 2){
count++;
}
}
return count;
}

int main(){
int n = 5;
vector<int> a = {4, 2, 2, 6, 7};
cout << numberOfGoodIndices(n, a);
}