From c52b36c6a37fdb1d1de146d3939cb42e2c691f44 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Sat, 5 Nov 2022 01:28:02 +0200 Subject: Solved 6 problem in filtrationContest and restructured the repo --- HackerRank/CountingSort2/CountingSort2.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 HackerRank/CountingSort2/CountingSort2.cpp (limited to 'HackerRank/CountingSort2/CountingSort2.cpp') diff --git a/HackerRank/CountingSort2/CountingSort2.cpp b/HackerRank/CountingSort2/CountingSort2.cpp new file mode 100644 index 0000000..29fb91c --- /dev/null +++ b/HackerRank/CountingSort2/CountingSort2.cpp @@ -0,0 +1,21 @@ +#include + +using namespace std; + +int main() { + int n, x; + cin >> n; + vector v; + vector freq(100); + for(int i = 0; i < n; i ++){ + cin >> x; + freq[x]+=1; + } + for(int i = 0; i < freq.size(); i++){ + for(int j = 0; j < freq[i]; j++){ + cout << i << " "; + } + } + cout << endl; + return 0; +} -- cgit v1.2.3