or stuff each string into a hashmap (python duct, js object) that maps each letter to a count of occurrences. then compare values and keys. both are linear operations, thus more optimal than sorting.
maps tend to be the more optimal solution to βfinding things in arrays using nested loopsβ than sorting.
sorting is more useful when you have space constraints β eg you can sort in place and then compare without hashmaps β or want to do additional work than exact comparison β eg navigate a tree representation of words in incremental ways.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
or stuff each string into a hashmap (python duct, js object) that maps each letter to a count of occurrences. then compare values and keys. both are linear operations, thus more optimal than sorting.
maps tend to be the more optimal solution to βfinding things in arrays using nested loopsβ than sorting.
sorting is more useful when you have space constraints β eg you can sort in place and then compare without hashmaps β or want to do additional work than exact comparison β eg navigate a tree representation of words in incremental ways.