Optimize & Solve Technique
Look for BUD
It's an acronym for:
- Bottlenecks
- Unnecessary work
- Duplicated work
Data Structure Brainstorm
We simply run through a list of data structures and try to apply each one.
Example
Keep track of the median of an array.
Structure Brainstorm
- Linked list? Probably not.
- Array? Maybe keep it sorted? It's expensive.
- Binary tree? Could be possible.
- Heap? You may use two heaps, one for the first half of the array (it will be a max heap) and one for the second half of the array (it will be a min heap). Best solution!