Machine Learning Engineer Coding & Algorithms Interview Questions
Practice the exact questions companies are asking right now.
Count subarrays summing to target
Question LeetCode 560. Subarray Sum Equals K – Given an integer array nums and an integer k, return the total number of continuous subarrays whose sum...
Solve matrix rotation and 1-D illumination
Question LeetCode 48. Rotate Image – rotate an n×n matrix 90° clockwise (extra space allowed). Find the point(s) with the maximum number of illuminate...
Find earliest supporting version under constraints
You are given version strings formatted as {major}.{minor}.{patch}, e.g., "103.003.03". Each version either supports a feature or not. You may call is...
Simulate bubble elimination and maximize common prefix
You are given two independent coding tasks (as in a multi-question OA). Solve each. Task A — Grid “bubble/candy” elimination simulation You are given ...
Compute minimal time to finish dependent tasks
Coding: Task Scheduling With Prerequisites (Parallel Allowed) You have n tasks labeled 1..n. Each task takes exactly 1 unit of time to complete. Some ...
Implement string-based rounding without floats
Coding You are not allowed to parse the input into a built-in floating type (to avoid overflow and precision issues). Work directly on strings. 1) Imp...
Write a generator for substring pattern matches
Problem Write a generator that scans a string and emits a value whenever a substring matches a given pattern. Input - A string s - A string pattern (n...
Find shortest transformation steps in a word graph
You are given two strings begin and end of the same length, and a list words of distinct strings (also same length). You can transform one string into...
Compute nested depth sum and grid distance
Problem A: Weighted sum of integers in a nested list You are given a nested list structure that may contain integers or other nested lists. Define the...
Solve shipping capacity and expression insertion
Problem A: Minimum shipping capacity You are given an array weights where weights[i] is the weight of the i-th package. Packages must be shipped in or...
Determine if a string can be segmented
Given a string s and a list of strings wordDict, determine whether s can be segmented into a sequence of one or more dictionary words. - You may reuse...
Solve linked list, tree, and grid problems
Problem A — Find cycle entry in a singly linked list You are given the head of a singly linked list. The list may contain a cycle. - Return the node w...
Implement TF-IDF scoring for documents
Problem Implement a simplified TF–IDF scorer. You are given: - A list of documents docs, where each document is a string. - A query string q. Tokeniza...
Return all root-to-leaf tree paths
Given the root of a binary tree, return all root-to-leaf paths. - A leaf is a node with no children. - A path should be represented as a string with n...
Choose K pickup locations minimizing L1 distance
Coding: K Shuttle Pickup Locations (L1) You are given the coordinates of N people on a 2D grid. You want to open K shuttle pickup locations (pickup po...
Implement weighted random city and sparse dot product
Question 1: Weighted random city picker You are given a mapping from city → population (all populations are positive integers). Implement a random gen...
Implement 2D convolution forward pass
Problem Implement the forward pass of a 2D convolution (conv2d) from scratch (no deep learning libraries). You are given: - Input tensor x with shape ...
Design a robot movement command system
Robot Movement (Pair Programming) You are given an empty starter repository (only a README). Implement a small, testable robot movement module that ca...
Implement K-means and solve interval/frequency tasks
Task 1 — Describe/implement K-means clustering Given: - A data matrix X with shape (n_samples, d). - An integer k (number of clusters). Explain (or wr...
Solve two linked list/array tasks
You are given two independent coding tasks. Task 1: Remove the N-th node from the end of a singly linked list Given the head of a singly linked list a...