Going through the first few exercises on Leetcode for fun and learning. 🥳
We'll aim to get the #1 (Elixir) solution for runtime performance, however there is some runtime variation on Leetcode which can't be avoided, and we only implement pure solutions. i.e. No processes/ETS.
Note, all problems were solved without AI assistance, however AI was used to help generate the solution notes.
General:
- Pay close attention to the problem description + constraints
- Focus on algorithmic complexity first
- Always consider trading space for speed
- Favour predictable, common codepaths over unpredictable branching
Elixir specific:
- If random reads are required, converting list -> tuple is normally the best approach
- Pattern matching + recursion often result in the most performant, simplest code
- Delegate to BIFs (built in functions) where possible
- For strings, operating on binary data/chars is faster than using functions which support unicode
Resources:
