This was my first day learning the trifles and techniques of leetcode. I realized that python is awesome to code in especially for OOP and data structure type problems. This day was definitely hard. This format of questions is not easy to get used to.
Some of my notes from that day:
- I'm learning about the different modules and imports that I can use. itertools is really nice for iterables. Makes combinations and concatenating really easy for lists
- Parameters are passed by reference, so be careful when mutating a parameter within a function. Also, if you were to append that parameter to something else, make a shallow copy first
so that you don't add that parameter which will change in other recursion iterations
- Backtracking is not very clear to me, but it seems like I've been doing recursion doing backtracking this entire time
- Tail recursion optimization is really nice for other languages, but doesn't work for Python. TRO is useful to use smaller stacks. It basically works by replacing each function stack with the function it calls
- Recursion is terrible for speed, but good for memory usage
- Add self as a parameter within helper functions
- Can add a function within a function in python
No comments:
Post a Comment