Meta Machine Learning Engineer Coding & Algorithms Interview Questions
Master your tech interview with our curated database of real questions from top companies.
Compute binary tree left-side view
Given a binary tree, return the values visible from the left side when looking from top to bottom. If multiple nodes exist at the same depth, the left...
Implement bounds, minimum, pathfinding, and moving average
Solve the following data-structures problems: ( 1) Given two sorted integer lists A and B, merge them into a single non-decreasing array. Then, for a ...
Implement exponentiation and link tree neighbors
Solve two independent tasks. Task A — Fast exponentiation: Implement fastExponent(x, n) that returns x raised to the integer power n, where x is a dou...
Find kth smallest in sorted matrix
Given an n x n matrix where each row and each column is sorted in nondecreasing order, and an integer k (1 ≤ k ≤ n^ 2), return the k-th smallest eleme...
Detect cycles and order with DFS
You are given a directed graph of package dependencies represented as an adjacency list: Map<String, List<String>> deps where deps[p] lists packages t...
Find kth smallest pair sum with heaps
You are given two nondecreasing arrays A (length n) and B (length m) of non-negative integers and an integer k (1 <= k <= n*m). Return the k-th smalle...
Return k smallest elements using heap
Given an unsorted array nums of up to 1,000,000 integers and an integer k (1 <= k <= nums.length), return the k smallest elements in ascending order. ...
Find connected region sizes in matrix
Given an m x n grid of characters grid and a target character ch, implement: ( 1) sizeOfRegion(grid, r0, c0, ch) -> int that returns the size of the 4...
Maximize one stock trade profit
You're given an array prices of length n where prices[i] is the stock price on day i. You may complete at most one transaction (buy once, then sell la...
Merge two sorted arrays in-place
You are given two nondecreasing arrays A and B, where A has enough trailing empty slots to hold all elements of B. Merge B into A in-place so that A r...
Optimize ribbon piece length by binary search
Given an array lengths of positive integers and an integer k, you may cut each element into pieces of integer length L > 0. Find the maximum L such th...
Generate unique permutations with duplicates
Given an array of integers that may contain duplicates, generate all unique permutations. Ensure no duplicate permutations are returned even if some v...
Solve matrix components, median, and traversals
1) Binary matrix component: Given an m x n grid of 0s (background) and 1s (objects), return the size of the largest connected component where connecti...
Check diagonal & compute window stats
Question Given a square matrix, determine whether all elements on its main diagonal are identical. LeetCode 346. Moving Average from Data Stream – des...
Check diagonal and compute window statistics
Question Given a square matrix, determine whether all elements on its main diagonal are identical. LeetCode 346. Moving Average from Data Stream – des...
Compute sliding-window medians
Given an array nums and an integer k, compute the median for each contiguous subarray (window) of length k and return the sequence of medians in order...
Check diagonal equality in a matrix
Given an m x n integer matrix, determine whether every top-left to bottom-right diagonal contains identical values (all elements along each such diago...
Solve matrix diagonal and sliding-window statistics
1) Given an m x n integer matrix, determine whether every top-left to bottom-right diagonal has the same value (Toeplitz property). Return true/false,...
Implement sliding-window moving average
Design a class MovingAverage that supports a constructor MovingAverage(k) and a method next(val) returning the average of the last k values from a dat...