You are viewing a single comment's thread. Return to all comments →
This solution works better than the other solutions discussed here.
import java.util.Scanner;
public class Solution {
public static void main(String[] args) { Scanner scan=new Scanner(System.in); int size=Integer.parseInt(scan.nextLine()); StringBuffer[] st=new StringBuffer[100]; for(int i=0;i<100;i++) { st[i]=new StringBuffer(); } for(int i=0;i<size;i++) { String sts=scan.nextLine(); String[] str=sts.split("[\\s]+"); int k=Integer.parseInt(str[0]); String s; if(i<size/2) s="- "; else s=str[1]+" "; st[k]=st[k].append(s); } for(int i=0;i<100;i++) { System.out.print(st[i]); } }
}
Seems like cookies are disabled on this browser, please enable them to open this website
The Full Counting Sort
You are viewing a single comment's thread. Return to all comments →
This solution works better than the other solutions discussed here.
import java.util.Scanner;
public class Solution {
}