During Practice
There are only two ways to store data structures: as arrays (sequential storage) or as linked lists (linked storage).
First of all, it should be clear that data structures are tools, and algorithms are methods to solve specific problems with appropriate tools.
- Use a plain-text editor as Scratchpad
- Record new techniques/algorithms
- It’s okay to look at solutions after a certain period of trying.
- Use syntactic sugar & libraries. Python has lots.
- Comment above every line while coding
During Testing
- Brute Force → Better Data Structures/Algorithms → Even better time complexity
- Always ask: can reduce Time Complexity even further?
- Exponential is never good. Polynomial is not enough. Linear time!
- Priority Queue / Hashmap / Dynamic Programming / Sliding Window Technique
- Try thinking: What property doesn’t change? What variable is constant?
- Try thinking: Invert the search; find the contrapositive
- Always ask: can reduce Time Complexity even further?
- Are you
{python}return
ing? - Edge cases
- infinite loops are probably not it
- ⇒ make the
while
loops conditioned on index boundaries
- Test the program yourself on a text editor
- Try to defeat the problem (find very weird test inputs)