We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Counting Sort 1
- Discussions
Counting Sort 1
Counting Sort 1
Sort by
recency
|
275 Discussions
|
Please Login in order to post a comment
include
using namespace std;
void countingSort(int a[], int n) { int freq[100] = {0}; for (int i = 0; i < n; i++) { freq[a[i]]++; } for (int i = 0; i < 100; i++) { cout << freq[i] << " "; } cout << endl; } int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } countingSort(a, n); return 0; }
Golang
C++20 ` vector countingSort(vector arr) { vector frequency(100); std::fill(frequency.begin(), frequency.end(), 0);
} `
Python
Swift