You are viewing a single comment's thread. Return to all comments →
Even simpler, you dont need 2 arrays. We can use a variable and an array.
Scanner in = new Scanner(System.in); int N= in.nextInt(); int[] a = new int[N]; for(int i=0;i<N;i++){ int p =in.nextInt(); a[p]++; } for(int j=0;j<100;j++){ for(int k=0;k<a[j];k++){ System.out.print(j +" "); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Counting Sort 2
You are viewing a single comment's thread. Return to all comments →
Even simpler, you dont need 2 arrays. We can use a variable and an array.