Interview Q&A / Machine Learning

INTERVIEW Q&A · 55 QUESTIONS

Machine Learning interview questions

Supervised vs unsupervised learning, overfitting, metrics and the classic models, explained simply.

  1. How do you restrict a generic type parameter using extends?

    Write T extends Something to say the caller may pass any type, as long as it has at least the shape of Something. Inside the function you can then safely use those members, such as .length or .id.

    BeginnerQuick answer1 min read
  2. How do you write a generic class in TypeScript, for example a Stack?

    Put the type parameter after the class name, like class Stack<T>, and use T in fields and method signatures. Each instance fixes T when created, so new Stack<number>() only accepts and returns numbers.

    BeginnerQuick answer1 min read
  3. How would you model an API response with a generic type?

    Define one generic interface such as ApiResponse<T> with a data: T field plus shared fields like status and message. Each endpoint then reuses it with its own data type, for example ApiResponse<User[]>.

    BeginnerQuick answer1 min read