Microsoft Software Engineer Interview Experience: Prime-Step Travel and House Robber Variants

Microsoft·Software Engineer·Nov 2026
Online Assessmentmedium

The first question was a House Robber variation with extra logic involving prime numbers, as follows.

Problem description

A traveler moves through cities represented by an integer array. Each integer gives the amount of money spent, if negative, or earned, if positive, in that city per day. The journey starts at city 0 and ends at city n-1. The traveler can move to the adjacent city or to a city p steps away, where p is a prime number ending in 3.

Determine the maximum money the traveler can have at the end.

Example

cities = [0, 100, 200, -500, -100, -150, -50].

The optimal journey ends with 100.

The traveler starts at city 0, moves to city 1 and earns 100, then to city 2 for 100 + 200 = 300, then to city 2 + 3 = 5 for 300 + (-150) = 150, and finally to city 6 for 150 + (-50) = 100.

The traveler only moves to city i+1 or i+3 here, since 3 is the only prime ending in 3 within this array's range.

Function description

Complete optimalJourneyTotal with the parameter int cities[n], where cities[i] is the money earned or spent in city i. Return an integer representing the maximum money at the end.

Constraints

1 <= n <= 10^4.
-10^4 <= cities[i] <= 10^4.
cities[0] = 0.

The second question was just LeetCode 2560 with a different story.

Published

Curated and edited by PracHub

Practice the questions from this interview

Discussion

Sign in to join the discussion. The author is notified of every comment.

Loading comments…

Interview at a glance

Company
Microsoft
Role
Software Engineer
Rounds
Online Assessment
Difficulty
medium
Interview date
Nov 2026
Questions from this interview
2 questions

Related interview experiences

Explore more interview rounds, questions, and outcomes.

Browse interview experiences