HackerRank Counting Sort 1 Problem Solution
HackerRank Counting Sort 1 Problem Solution
HackerRank
CLOSE ADS Counting Sort 1 problem solution CLOSE ADS
In this HackerRank Counting Sort 1 problem, you have given a list of integers, count and
return the number of times each value appears as an array of integers.
Search
Subscribe To Channel
Programmingoneonone
YouTube 797
ar = CLOSE
list(map(int,
ADS input().split())) CLOSE ADS
tot = [0]*100
HackerRank Diagonal
public class Solution { Difference problem solution
March 23, 2021
int main() {
int n, val;
int A[100];
for (int i = 0; i < 100; i++) {
A[i] = 0;
}
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &val);
A[val]++;
}
printf("%d", A[0]);
for (int i = 1; i < 100; i++) {printf(" %d", A[i]);}
printf("\n");
return 0;
}
int main()
{
int i,j,n,a[1000001];
int c[100]={0};
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
c[a[i]]++;
}
for(i=0;i<100;i++)
printf("%d ",c[i]);
printf("\n");
/* Enter your code here Read input from STDIN Print output
/ Enter your code here. Read input from STDIN. Print output
to STDOUT */
return 0;
}
function processData(input) {
var lines = input.split('\n'),
len = parseInt(lines[0], 10);
console.log(A.join(" "));
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
var _input = "";
process.stdin.on("data", function (input) { _input += input; });
process.stdin.on("end", function () { processData(_input); });
Facebook Twitter