Timeline for Checking if two strings are anagrams in Python
Current License: CC BY-SA 4.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 8, 2018 at 15:55 | comment | added | nemo | @Peilonrayz Thank you for writing how you calculated the O complexity for your function it is really helpful! Is there an online resource you recommend for understanding how to know/make the run time calculations? | |
Jun 8, 2018 at 15:08 | history | edited | Peilonrayz♦ | CC BY-SA 4.0 |
added 181 characters in body
|
Jun 8, 2018 at 15:06 | comment | added | Peilonrayz♦ | @JAD it's not that great an improvement. I don't think it's better, just different. The docs that I linked to say how you can use it. For you I can include it. | |
Jun 8, 2018 at 13:46 | comment | added | JAD | What I meant to say that for such an improvement in completixy, you didn't put a lot of emphasis on that method. What does it do? Why is it better? How to use it? I think it would be a good addition to the review. | |
Jun 8, 2018 at 13:38 | comment | added | Peilonrayz♦ | @JAD what do you mean "work it out?" Have you tried swapping them out? | |
Jun 8, 2018 at 13:19 | comment | added | JAD |
About the collections.Counter , could you work that out please? It might be useful for OP to see another solution.
|
|
Jun 8, 2018 at 8:30 | comment | added | Peilonrayz♦ | @Bass You're right, you can do that. | |
Jun 8, 2018 at 8:29 | history | edited | Peilonrayz♦ | CC BY-SA 4.0 |
Update complexity, so it's correct.
|
Jun 8, 2018 at 7:13 | comment | added | Bass | Just a minor point on the complexity: the length check at the beginning will short circuit unless a equals b. Because of this, and the fact that the big-O eats any constant coefficients, \$\mathcal{O}(a\log{a} + b\log{b})\$ is actually equal to just \$\mathcal{O}(a\log{a})\$ in this case. | |
Jun 7, 2018 at 16:09 | vote | accept | nemo | ||
Jun 7, 2018 at 16:09 | comment | added | nemo | Oh wow that was a really fast to the point answer thank you ! I didn't realize the time complexity would be that of the sorted function. Awesome good to know someone would be okay with getting an answer with builtin functions :D | |
Jun 7, 2018 at 15:54 | history | answered | Peilonrayz♦ | CC BY-SA 4.0 |