PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Microsoft

Solve cache, grid path, and substring problems

Last updated: Mar 29, 2026

Quick Overview

This multipart question evaluates algorithmic problem-solving and data structure design skills, covering a capacity-bounded cache with eviction behavior, path score optimization on a grid, and longest non-repeating substring detection.

  • hard
  • Microsoft
  • Coding & Algorithms
  • Software Engineer

Solve cache, grid path, and substring problems

Company: Microsoft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Onsite

You are given three independent coding tasks. ## 1) Bounded cache with eviction Design a data structure that stores key–value pairs with a fixed capacity and supports: - `get(key) -> value`: - Return the value if `key` exists, otherwise return `-1`. - Mark the key as **most recently used**. - `put(key, value)`: - Insert or update the value. - Mark the key as **most recently used**. - If inserting causes the number of keys to exceed `capacity`, evict exactly one key: the **least recently used** key. **Requirements** - Aim for **O(1)** average time per operation. **Constraints (typical)** - `1 <= capacity <= 10^5` - Up to `10^5` operations. ## 2) Maximize the minimum value on a grid path You are given an `m x n` integer grid `grid`. A path starts at `(0,0)` and ends at `(m-1,n-1)`, moving only in 4 directions (up/down/left/right) within bounds. Define the **score** of a path as the **minimum** value among all cells on the path. Return the **maximum possible score** among all valid paths. **Constraints (typical)** - `1 <= m, n <= 100` - Cell values are integers within a reasonable range (e.g., `0..10^9`). ## 3) Longest substring without repeating characters Given a string `s`, return the length of the longest contiguous substring that contains **no repeated characters**. **Constraints (typical)** - `0 <= |s| <= 10^5` - `s` may contain ASCII/Unicode characters (clarify with interviewer if needed).

Quick Answer: This multipart question evaluates algorithmic problem-solving and data structure design skills, covering a capacity-bounded cache with eviction behavior, path score optimization on a grid, and longest non-repeating substring detection.

Related Interview Questions

  • Return Top K Open Businesses - Microsoft (hard)
  • Implement Memory Allocation and In-Memory Records - Microsoft (medium)
  • Implement K-Means and Detect Divisible Subarrays - Microsoft (medium)
  • Sort Three Categories In Place - Microsoft (medium)
  • Retain Top K Elements - Microsoft (medium)
Microsoft logo
Microsoft
Feb 11, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
2
0
Loading...

You are given three independent coding tasks.

1) Bounded cache with eviction

Design a data structure that stores key–value pairs with a fixed capacity and supports:

  • get(key) -> value :
    • Return the value if key exists, otherwise return -1 .
    • Mark the key as most recently used .
  • put(key, value) :
    • Insert or update the value.
    • Mark the key as most recently used .
    • If inserting causes the number of keys to exceed capacity , evict exactly one key: the least recently used key.

Requirements

  • Aim for O(1) average time per operation.

Constraints (typical)

  • 1 <= capacity <= 10^5
  • Up to 10^5 operations.

2) Maximize the minimum value on a grid path

You are given an m x n integer grid grid. A path starts at (0,0) and ends at (m-1,n-1), moving only in 4 directions (up/down/left/right) within bounds.

Define the score of a path as the minimum value among all cells on the path.

Return the maximum possible score among all valid paths.

Constraints (typical)

  • 1 <= m, n <= 100
  • Cell values are integers within a reasonable range (e.g., 0..10^9 ).

3) Longest substring without repeating characters

Given a string s, return the length of the longest contiguous substring that contains no repeated characters.

Constraints (typical)

  • 0 <= |s| <= 10^5
  • s may contain ASCII/Unicode characters (clarify with interviewer if needed).

Submit Your Answer to Earn 20XP

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 8,000+ 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.