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.
Easy to read and understand compared to the other solutions though it will have overall time complexity is O(n).
nice you are now 4kyu !!!! asking make you more smarter!
Very nicely done.
This comment is hidden because it contains spoiler information about the solution
Best solution, imho
Js array split and join method both use for loops underneath the hood making your solution have a time complexity of O(n + m) but solving in string without converting to array the for loop runs only once and gives a better solutions with O(n) time complexity.
This is inetresting take on the problem. I am trying to figure this out.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
@Me2loveit2 Unless if there is an n log n algorithm for finding palindromes in substrings, the worst case should always be n^2. You can do a bunch of micro-optimizations that will make it slightly faster, but nothing to change the worst case.
PS: Your solution is very jumbled. Couldn't really be bothered to follow it through to the end to figure out the time complexity. But iterating twice over the string with capture matches to find the center of palindromes is already n^2. Then you go through that list and find the centers inside the original string... Why even match them in the first place, if you are just going to find them again? It would make sense that you would time out because you have a bunch of redundancies that are completely unnecessary.
This comment is hidden because it contains spoiler information about the solution
Not the best practice, its performance is always O(n^2) regardless of the input.
There are ways to loop cleverly to improve the performance significantly for some inputs.