Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This solution has a time complexity of O(n^2) in the worst case scenario, where n is the length of the input string.
This is due to the use of the contains() method, which loops through the remaining substring to check if a character appears more than once.
In the worst case scenario, this will cause the loop to be repeated n times, resulting in O(n^2) time complexity.
is it be more better if we use {for}?
yes, i have same opinion, using api to simplify the code but it have poor performance
Kind of embarassing that a O(n^2) is this high up :/
Nice job!
If in a more general case (not restricted to 26 english character and 10 digits), this method's time complexity could be O(n^2), which I think is not good enough...
this solution doesnt work at all, replace ask for char to char rather than string to string.