PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Microsoft

Implement Matrix Move and Logger

Last updated: Apr 12, 2026

Quick Overview

This question evaluates array manipulation and in-place algorithm design for handling overlapping submatrix moves, along with data-structure and time-window reasoning for implementing a rate-limited logger that supports O(1)-average-time checks and bounded memory.

  • medium
  • Microsoft
  • Coding & Algorithms
  • Software Engineer

Implement Matrix Move and Logger

Company: Microsoft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Implement the following two coding tasks. 1. **Move a submatrix in place.** You are given an `m x n` matrix, a source rectangle defined by its top-left corner `(r1, c1)` and bottom-right corner `(r2, c2)` inclusive, and a destination top-left corner `(nr, nc)`. The destination rectangle has the same height and width as the source rectangle. Update the original matrix **in place** so that the destination rectangle contains exactly the original values from the source rectangle. The source and destination rectangles may overlap, and the final destination contents must match what you would get if the source rectangle had been copied before any writes occurred. Use only `O(1)` extra space besides a few temporary variables. 2. **Implement a rate-limited logger.** Design a `Logger` class with a configurable time window `windowSeconds` and a method `shouldAllow(key, timestamp) -> bool`. A request for `key` should be allowed only if the same key has not been allowed during the previous `windowSeconds` seconds. Assume timestamps are non-decreasing. Your implementation should support high call volume with `O(1)` average-time checks and should remove expired state so memory usage does not grow without bound.

Quick Answer: This question evaluates array manipulation and in-place algorithm design for handling overlapping submatrix moves, along with data-structure and time-window reasoning for implementing a rate-limited logger that supports O(1)-average-time checks and bounded memory.

Related Interview Questions

  • Sort Three Categories In Place - Microsoft (medium)
  • Implement K-Means and Detect Divisible Subarrays - Microsoft (medium)
  • Implement SFT Sample Packing - Microsoft (medium)
  • Implement SQL Table and DNA Ordering - Microsoft (medium)
  • Solve power jumps and graph tour - Microsoft (hard)
Microsoft logo
Microsoft
Feb 22, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
0
0
Loading...

Implement the following two coding tasks.

  1. Move a submatrix in place. You are given an m x n matrix, a source rectangle defined by its top-left corner (r1, c1) and bottom-right corner (r2, c2) inclusive, and a destination top-left corner (nr, nc) . The destination rectangle has the same height and width as the source rectangle. Update the original matrix in place so that the destination rectangle contains exactly the original values from the source rectangle. The source and destination rectangles may overlap, and the final destination contents must match what you would get if the source rectangle had been copied before any writes occurred. Use only O(1) extra space besides a few temporary variables.
  2. Implement a rate-limited logger. Design a Logger class with a configurable time window windowSeconds and a method shouldAllow(key, timestamp) -> bool . A request for key should be allowed only if the same key has not been allowed during the previous windowSeconds seconds. Assume timestamps are non-decreasing. Your implementation should support high call volume with O(1) average-time checks and should remove expired state so memory usage does not grow without bound.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Microsoft•More Software Engineer•Microsoft Software Engineer•Microsoft Coding & Algorithms•Software 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.