PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Meta

Solve matrix diagonal and sliding-window statistics

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithmic problem-solving and data-structure design skills, covering streaming algorithms, sliding-window statistics (moving average and median), and matrix property recognition (Toeplitz), and is categorized under Coding & Algorithms for Machine Learning Engineer roles.

  • Medium
  • Meta
  • Coding & Algorithms
  • Machine Learning Engineer

Solve matrix diagonal and sliding-window statistics

Company: Meta

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

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, analyze time and space complexity, and describe how to handle a streaming input of rows. 2) 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( 1) time and O(k) space. Address numerical precision, overflow, and behavior when the stream has fewer than k elements. 3) 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.

Quick Answer: This question evaluates algorithmic problem-solving and data-structure design skills, covering streaming algorithms, sliding-window statistics (moving average and median), and matrix property recognition (Toeplitz), and is categorized under Coding & Algorithms for Machine Learning Engineer roles.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
  • Solve Two Backtracking Array Problems - Meta (hard)
  • Solve Maze and Suffix Problems - Meta (medium)
Meta logo
Meta
Jul 31, 2025, 12:00 AM
Machine Learning Engineer
Technical Screen
Coding & Algorithms
2
0
  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, analyze time and space complexity, and describe how to handle a streaming input of rows.
  2. 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(
  3. time and O(k) space. Address numerical precision, overflow, and behavior when the stream has fewer than k elements.
  4. 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.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Machine Learning Engineer•Meta Machine Learning Engineer•Meta Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.