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.
Why are all of these solutions O(n^2)?
is it O(N^2) time complexity? O(N) for removing and adding elements to Linked List, bur removing inside forloop... i think O(N * N). Or not?
Stevele like your solution man, keep it up.
This is not the most optimized solution, given the constraints of the problem.
LinkedList remove funtion will traverse the entire list with each call, which is really not needed. Use of an array of size 26 will ensure constant space complexity (as we are not growing linearly) and constant time reach to each character's count (eliminating need for HashMap or something similar).
You can refer to my solution for comparison. If I am missing some advantage you gain by using linked list, please do reply. I'd love to know! :)
This program runs in O(N*M) since
str1.contains(s) is O(N) with N = length(str1), M = length(str2)
Using List it takes O(N) only, N = max length of (str1, str2).
This comment is hidden because it contains spoiler information about the solution