diff --git a/README.md b/README.md index 0f36214..f66cc69 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,5 @@ -# Competitive Programming Assignment - -Solve the following problems: -1. Given an array of size n arrange the array in such a way that all even numbers comes before all odd numbers and the order should be maintained -Example - 13 25 6 24 45 2 -Output - 6 24 2 13 25 45 - - -2. Given an array of size n print the array element and it's frequency. (Order not mandatory) -Example - 2 4 2 2 3 3 3 5 -Output: -2 - 3 -3 - 3 -4 - 1 -5 - 1 - -# Instructions to upload - -- Fork the repository -- Create a new branch (with your name) -- Upload files in the new branch. -- Create a pull request. - +Arnab Chatterjee +B.tech CSE AI +1st year +F4 +211003003032 diff --git a/first.cpp b/first.cpp new file mode 100644 index 0000000..b0807b6 --- /dev/null +++ b/first.cpp @@ -0,0 +1,77 @@ +#include +#include +using namespace std; + +vector makeArray(int n) +{ + vector ar; + for(int i=0;i> t; + ar.push_back(t); + } + cout << endl; + + return ar; +} + +void usingTime(vector arr,int n) +{ + for(int i=0;i arr,int n) +{ + vector even,odd; + + for(int i=0;i> n; + vector arr = makeArray(n); + + //approch using time complexity O(n^2) + usingTime(arr,n); + + // approch using space complexity O(n) + usingSpace(arr,n); + + return 0; +} \ No newline at end of file diff --git a/second.cpp b/second.cpp new file mode 100644 index 0000000..c67535d --- /dev/null +++ b/second.cpp @@ -0,0 +1,21 @@ +#include +#include +#include +#define rep(i,a,b) for(int i=a;i> n; + vector arr; + unordered_map m; + rep(i,0,n) {int temp; cin >> temp; arr.push_back(temp);} + rep(i,0,n) m[arr[i]]++; + unordered_map ::iterator it = m.begin(); + while(it!=m.end()){ + cout << it->first << "-" << it->second << endl; + it++; + } + return 0; +} \ No newline at end of file