GO TO A SECTION

↑ ↓ to navigate · Enter to openExplore all sections →
FDEInterviews logo
← Coding & DSA / 69
mediumAmazonAppleMeta

Implement a k-nearest-neighbors classifier from scratch.

There is no training, just storage; the work is at query time. The signal is whether you vectorize the distance computation, break ties sensibly, and know when O(n) per query forces you onto an ANN index instead.

Updated Aug 2026 · Grounded in real Forward Deployed Engineer interview loops and written to a senior-engineer editorial bar.

There is no training, just storage; the work is at query time. The signal is whether you vectorize the distance computation, break ties sensibly, and know when O(n) per query forces you onto an ANN index instead.

20 answers per topic instead of 10, plus saved progress and bookmarks · no cardor unlock all 559 remaining answers · ₹2,000 / $25

Every answer, concept and course, every paper breakdown, all published video lessons, hands-on FDE Lab missions, Premium PDF guides and companion files, the full practice-test bank and work-sample downloads. Referral Premium excludes guide PDFs and their companion files.

6 months · One payment · No auto-renewal

Study alongside free video lessons.

Keep practising

FEDITOR'S NOTE

k-NN is the easiest model to state and the easiest to get subtly wrong. Interviewers watch for the tie-break (even k with a split vote), distance-weighting, and whether you mention that this is O(n*d) per query with zero training, which is the exact tradeoff that makes it useless at scale without an approximate index. Quote 'lazy learner' and explain what lazy buys and costs you.

DISCUSSION · 0

No comments yet — be the first to share your approach.