for this test case , my code is not working
4
bat
bat
apple
batman
All Test cases has passed but when Strings will same , test case failed
You need to implement a custom comparator function for this. It should work like this:- First calculate the length of smaller string and extract substrings of that length from both of the strings and check to see if they are equal, if they are equal, then longer string should be placed first. else use normal compareTo function to compare the two strings.
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.