I am not able to figure out my mistake, the test case is failing!
This is the link to my code-
I am not able to figure out my mistake, the test case is failing!
This is the link to my code-
u can directly use the Collections.sort(answer);
to sort the string
you will later learn a better way to sort laxographically
Yeah well it worked now, thanks for that. I still have the question that why didn’t it work with my sorting code even though I was getting correct answer with it.
String[] s={“dek”,“dep”,“d”,“dekk”,“deep”,“de”,“ced”}; //
for(int i=0;i<s.length-1;i++){ ///BUBBLE SORT
for(int j=0;j<s.length-1-i;j++){
if(s[j].compareTo(s[j+1])>0){ //if s[j]> s[j+1] then it gives +ve integer
String t=s[j]; //if s[j]<s[j+1] == gives -ve value
s[j]=s[j+1]; // s[j]==s[j+1]== give 0
s[j+1]=t;
}
}
}
bro this is the simplest way to sort the str laxog.
Yeah I got it. Thanks sir.