Day 10: Static Arrays
Today I went through the static arrays module in the neetcode DSA course and solved the corresponding leetcode problems. I learned about Big-O times in arrays and got experience using them in leetcode problems.
Today's Leetcode Problems and Review / Reflections
26. Remove Duplicates from Sorted Array
Review
the type of question
- Arrays
how you did well / messed it up
- In the beginning I had trouble because I was not familiar with the two pointers pattern. Afterwards, it became clear.
the lessons you learned (i.e. the benefit of using a heap vs map-based approach for this particular question, some Javascript syntax, a bad habit of forgetting to debug your code, a new search algorithm)
- non-decreasing order is essentially saying increasing order but duplicates can exist
- two pointer approaches can be very helpful for questions that should be solved in-place without taking up extra memory
“intuitive” takeaways from the question.
- two pointer approaches can help
Reflections
Exploring various solutions and clearly communicating them.
- I could have done better as I was mainly following the neetcode tutorial
Stating the runtime and space complexity (the pros and cons) of each solution.
- yes I did this, for example 0(n) runtime complexity with 0(1) space complexity
Translating ideas into code.
- yes
Debugging your code (visually inspecting your code. Walk through your code with an example, by hand. Edge cases too. This is NOT about running the code in your IDE to check that it works).
- I should have done this but didn't
Review
the type of question
- Arrays
how you did well / messed it up
- After problem 26, this was very easy
the lessons you learned (i.e. the benefit of using a heap vs map-based approach for this particular question, some Javascript syntax, a bad habit of forgetting to debug your code, a new search algorithm)
- two pointer approaches can be very helpful for questions that should be solved in-place without taking up extra memory
“intuitive” takeaways from the question.
- two pointer approach
Reflections
Exploring various solutions and clearly communicating them.
- I could have done better as I immediately went for the two pointer approach. In an interview I would aim to discuss my solution and potential approaches before coding.
Stating the runtime and space complexity (the pros and cons) of each solution.
- yes I did this, for example 0(n) runtime complexity with 0(1) space complexity
Translating ideas into code.
- yes
Debugging your code (visually inspecting your code. Walk through your code with an example, by hand. Edge cases too. This is NOT about running the code in your IDE to check that it works).
- I should have done this but didn't. I should in future problems.