Day 32 of 133

ML coding consolidation + design pattern review

Re-implement one classifier with a clean OO API. Reflect on SOLID violations.

DSA · NeetCode Two Pointers

  • Trapping Rain WaterDSA · Two Pointers

    Interview questions to prep

    1. Compare DP (precompute left-max, right-max) vs two-pointer O(1) space — walk through the two-pointer invariant.
    2. What if rainwater can flow off the sides — how does that change anything?

ML · Coding from scratch

  • Code k-NN classifier from scratchTraditional MLalirezadir

    Interview questions to prep

    1. Implement k-NN from scratch and explain its time/space complexity.
    2. How would you speed up k-NN inference on millions of points without changing the prediction?
  • Code k-means from scratchTraditional MLalirezadir

    Interview questions to prep

    1. Implement k-means with k-means++ initialization.
    2. Why does k-means++ initialization matter, and what does it cost vs random init?
  • Code logistic regression with SGDTraditional MLalirezadir

    Interview questions to prep

    1. Implement logistic regression with mini-batch SGD and L2 regularization.
    2. What numerical-stability pitfalls do you watch out for when implementing the sigmoid + log-loss?
  • Interview questions to prep

    1. Implement linear regression training with vectorized gradients and a learning-rate parameter.
    2. How do you verify your from-scratch implementation against sklearn or a closed-form OLS solution?

SWE · Design patterns

  • Creational: factory, builder, singletonTraditional MLRefactoring.guru

    Interview questions to prep

    1. When is a singleton an anti-pattern in tests?
    2. Compare factory vs abstract factory vs builder.
  • Structural: adapter, decorator, facadeTraditional MLRefactoring.guru

    Interview questions to prep

    1. When would you reach for an adapter vs a facade?
    2. Where does the decorator pattern show up cleanly in an ML inference pipeline?
  • Behavioral: strategy, observer, commandTraditional MLRefactoring.guru

    Interview questions to prep

    1. Show how the strategy pattern lets you swap ML models without touching call sites.
    2. When does observer cause subtle bugs in a high-throughput system?

References & further reading