String sort (first testcase wrong)

showing first testcase wrong

4
ap
apple
bat
batman
This is the first test case if you want to debug your code

i have checked this , this my code is giving correct for this code , you please it sir once , what is wrong in it. i have debugged it and and in eclipse also it is giving correct ansa

The second test case is a very long one. Also I’m not able to get your approach
One thing you can do is Arrays.sort the input string. It does the same thing

this will sort in lexicographical way also ?

Yes. It handles the lexicographical order as well. Are you done with it?

no sir its still not working

Traverse the list taking two elements at a time. Check if the first element is a subset of the second, swap them, else do Arrays.sort(arr).
The first testcase checks the subset code, the second test case is a long 500 words test case, all of same size which needs just sorting.
If you’re still not able to do, you’ll have to see the correct code

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.