Solve matrix diagonal and sliding-window statistics
Meta
Jul 31, 2025, 12:00 AM
Machine Learning Engineer
Technical Screen
Coding & Algorithms
0
0
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, analyze time and space complexity, and describe how to handle a streaming input of rows.
Design a data structure that maintains the moving average of the last k numbers in a real-time stream. Support push(x) and query() in amortized O(
time and O(k) space. Address numerical precision, overflow, and behavior when the stream has fewer than k elements.
Given an array nums and a window size k, output the median of each sliding window across the array. Achieve O(n log k) time or better. Explain the data structures you would use, how you handle duplicates and even k, and discuss memory trade-offs.