August 2024
Intermediate to advanced
516 pages
11h 47m
English
Another helpful optimization technique is to imagine what would happen if we stored our given data in an alternative data structure.
For example, we may be working on a problem where the data is given to us in the form of an array. However, reimagining that same data stored as a hash table, tree, or other data structure can sometimes reveal clever optimization opportunities.
Our use of a hash table for the magical lookup technique earlier is a specific example of this. And we’re about to see that changing the data structure can be useful for other scenarios as well.
Here’s one example. Let’s say we’re writing a function that determines whether two given strings are anagrams of one another. We encountered ...
Read now
Unlock full access