Day 28 of 133
ML coding from scratch — k-means, kNN, logistic regression
Implement, time, debug. The most-skipped form of practice.
DSA · NeetCode Heap / Priority Queue
- Kth Largest Element IN A StreamDSA · Heap / Priority Queue
Interview questions to prep
- Why is a heap the right structure? Could a balanced BST or sorted list work — why is heap better?
- Explain the heap-of-k pattern: keep size k, push new, pop if over k. What's the resulting complexity?
- What does the comparator look like, and how would you tweak it to flip min/max behaviour?
- Last Stone WeightDSA · Heap / Priority Queue
Interview questions to prep
- Why is a heap the right structure? Could a balanced BST or sorted list work — why is heap better?
- Explain the heap-of-k pattern: keep size k, push new, pop if over k. What's the resulting complexity?
- What does the comparator look like, and how would you tweak it to flip min/max behaviour?
ML · Coding from scratch
Interview questions to prep
- Implement k-NN from scratch and explain its time/space complexity.
- How would you speed up k-NN inference on millions of points without changing the prediction?
Interview questions to prep
- Implement k-means with k-means++ initialization.
- Why does k-means++ initialization matter, and what does it cost vs random init?
Interview questions to prep
- Implement logistic regression with mini-batch SGD and L2 regularization.
- What numerical-stability pitfalls do you watch out for when implementing the sigmoid + log-loss?
Interview questions to prep
- Implement linear regression training with vectorized gradients and a learning-rate parameter.
- How do you verify your from-scratch implementation against sklearn or a closed-form OLS solution?
References & further reading