Problem database last updated: June 20, 2025

MMorgan Stanley logo

Morgan Stanley Coding Interview Questions

49 problems · 13 Easy, 28 Medium, 8 Hard · Ranked #42 of 458

Difficulty breakdown

13 Easy

27% · avg 23%

28 Medium

57% · avg 59%

8 Hard

16% · avg 18%

Top topics

array
65.3%
string
26.5%
dynamic-programming
24.5%
hash-table
24.5%
two-pointers
18.4%
sorting
14.3%

Interview profile

Based on 49 reported problems, Morgan Stanley interviews are in line with industry averages - 16% Hard vs 18% overall. The majority (57%) of questions are Medium difficulty, which is typical for companies that want to see solid fundamentals without excessive trick questions.

Compared to the industry average, Morgan Stanley puts unusual emphasis on binary-indexed-tree (4.1% of problems, 9.2x the industry average), queue (4.1% of problems, 2.8x the industry average), prefix-sum (6.1% of problems, 1.8x the industry average). If you're short on time, these are the categories to double down on.

The most common topics are array (65.3%), string (26.5%), dynamic-programming (24.5%), hash-table (24.5%). Problems below are sorted by frequency, the ones at the top are asked most often.

All 49 problems

Best Time to Buy and Sell Stock

Solve

You are given an array prices where prices[i] is the price of a given stock on the ith day.

EasyVery Likely
arraydynamic-programming

Best Team With No Conflicts

Solve

You are the manager of a basketball team. For the upcoming tournament, you want to choose the team with the highest overall score. The score of the team is the...

MediumVery Likely
arraydynamic-programmingsorting

Minimum Cost to Move Chips to The Same Position

Solve

We have n chips, where the position of the ith chip is position[i].

EasyVery Likely
arraymathgreedy

Find The Original Array of Prefix Xor

Solve

You are given an integer array pref of size n. Find and return the array arr of size n that satisfies:

MediumVery Likely
arraybit-manipulation

The Employee That Worked on the Longest Task

Solve

There are n employees, each with a unique id from 0 to n - 1.

EasyVery Likely
array

Find the Longest Valid Obstacle Course at Each Position

Solve

You want to build some obstacle courses. You are given a 0-indexed integer array obstacles of length n, where obstacles[i] describes the height of the ith obsta...

HardVery Likely
arraybinary-searchbinary-indexed-tree

Find Subarrays With Equal Sum

Solve

Given a 0-indexed integer array nums, determine whether there exist two subarrays of length 2 with equal sum. Note that the two subarrays must begin at differen...

EasyVery Likely
arrayhash-table

Count Subarrays With Fixed Bounds

Solve

You are given an integer array nums and two integers minK and maxK.

HardVery Likely
arrayqueuesliding-window

Merge Intervals

Solve

Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cove...

MediumLikely
arraysorting

Two Sum

Solve

Given an array of integers nums and an integer target, return the indices of the two numbers that add up to target.

EasyLikely
arrayhash-map

First Missing Positive

Solve

Given an unsorted integer array nums. Return the smallest positive integer that is not present in nums.

HardLikely
arrayhash-table

Longest Substring Without Repeating Characters

Solve

Given a string s, find the length of the longest substring without duplicate characters.

MediumLikely
hash-tablestringsliding-window

3Sum

Solve

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

MediumLikely
arraytwo-pointerssorting

Kth Largest Element in an Array

Solve

Given an integer array nums and an integer k, return the kth largest element in the array.

MediumLikely
arraydivide-and-conquersorting

Group Anagrams

Solve

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

MediumLikely
arrayhash-tablestring

LRU Cache

Solve

Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.

MediumLikely
hash-tablelinked-listdesign

Minimum Number of Refueling Stops

Solve

A car travels from a starting position to a destination which is target miles east of the starting position.

HardLikely
arraydynamic-programminggreedy

Copy List with Random Pointer

Solve

A linked list of length n is given such that each node contains an additional random pointer, which could point to any node in the list, or null.

MediumLikely
hash-tablelinked-list

Make K-Subarray Sums Equal

Solve

You are given a 0-indexed integer array arr and an integer k. The array arr is circular. In other words, the first element of the array is the next element of t...

MediumLikely
arraymathgreedy

Contiguous Array

Solve

Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1.

MediumLikely
arrayhash-tableprefix-sum

Decode Ways

Solve

You have intercepted a secret message encoded as a string of numbers. The message is decoded via the following mapping:

MediumSometimes
stringdynamic-programming

Word Search

Solve

Given an m x n grid of characters board and a string word, return true if word exists in the grid.

MediumSometimes
arraystringbacktracking

Rotate List

Solve

Given the head of a linked list, rotate the list to the right by k places.

MediumSometimes
linked-listtwo-pointers

Number of Islands

Solve

Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.

MediumSometimes
arraydepth-first-searchbreadth-first-search

Coin Change II

Solve

You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

MediumSometimes
arraydynamic-programming

Kth Missing Positive Number

Solve

Given an array arr of positive integers sorted in a strictly increasing order, and an integer k.

EasySometimes
arraybinary-search

Minimum Operations to Reduce X to Zero

Solve

You are given an integer array nums and an integer x. In one operation, you can either remove the leftmost or the rightmost element from the array nums and subt...

MediumSometimes
arrayhash-tablebinary-search

Palindrome Linked List

Solve

Given the head of a singly linked list, return true if it is a palindrome or false otherwise.

EasySometimes
linked-listtwo-pointersstack

Count Binary Substrings

Solve

Given a binary string s, return the number of non-empty substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings...

EasySometimes
two-pointersstring

Min Stack

Solve

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

MediumSometimes
stackdesign

Count of Integers

Solve

You are given two numeric strings num1 and num2 and two integers maxsum and minsum. We denote an integer x to be good if:

HardSometimes
mathstringdynamic-programming

Subtree of Another Tree

Solve

Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false oth...

EasySometimes
treedepth-first-searchstring-matching

Reverse String

Solve

Write a function that reverses a string. The input string is given as an array of characters s.

EasySometimes
two-pointersstring

Subarrays with K Different Integers

Solve

Given an integer array nums and an integer k, return the number of good subarrays of nums.

HardSometimes
arrayhash-tablesliding-window

Remove Duplicates from Sorted Array

Solve

Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order o...

EasySometimes
arraytwo-pointers

House Robber

Solve

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from rob...

MediumSometimes
arraydynamic-programming

Valid Parentheses

Solve

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

EasySometimes
stringstack

Reverse Words in a String

Solve

Given an input string s, reverse the order of the words.

MediumSometimes
two-pointersstring

Longest Palindromic Substring

Solve

Given a string s, return the longest palindromic substring in s.

MediumSometimes
two-pointersstringdynamic-programming

Maximum Subarray

Solve

Given an integer array nums, find the subarray with the largest sum, and return its sum.

MediumSometimes
arraydivide-and-conquerdynamic-programming

Subarray Sum Equals K

Solve

Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.

MediumSometimes
arrayhash-tableprefix-sum

Steps to Make Array Non-decreasing

Solve

You are given a 0-indexed integer array nums. In one step, remove all elements nums[i] where nums[i - 1] > nums[i] for all 0 < i < nums.length.

MediumSometimes
arraylinked-listdynamic-programming

Count of Range Sum

Solve

Given an integer array nums and two integers lower and upper, return the number of range sums that lie in [lower, upper] inclusive.

HardSometimes
arraybinary-searchdivide-and-conquer

Stamping The Sequence

Solve

You are given two strings stamp and target. Initially, there is a string s of length target.length with all s[i] == '?'.

HardSometimes
stringstackgreedy

Jump Game

Solve

You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length...

MediumSometimes
arraydynamic-programminggreedy

Generate Parentheses

Solve

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

MediumSometimes
stringdynamic-programmingbacktracking

Letter Combinations of a Phone Number

Solve

Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order.

MediumSometimes
hash-tablestringbacktracking

Sort Colors

Solve

Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order...

MediumSometimes
arraytwo-pointerssorting

Next Greater Element I

Solve

The next greater element of some element x in an array is the first greater element that is to the right of x in the same array.

EasySometimes
arrayhash-tablestack

How often are these problems asked?

Frequency scores are based on crowdsourced interview reports. A higher score means the problem has been reported more often in recent Morgan Stanley interviews.

Very Likely

75-100%

Likely

50-74%

Sometimes

25-49%

Rare

0-24%

Preparing for your Morgan Stanley coding interview

Morgan Stanley interviews focus heavily on array, string, dynamic-programming problems. If you're short on time, these are the categories to prioritize. The problems on this page are sorted by frequency, so start from the top and work your way down.

Beyond solving problems, practice explaining your approach. Morgan Stanley interviewers care about your thought process - how you break down a problem, consider edge cases, and evaluate tradeoffs between solutions. A clean O(n) solution you can explain clearly beats an O(log n) solution you can't articulate.

Looking for more companies? Browse all 458 companies in our directory, or sharpen your fundamentals with our free data structure visualizers and AI-powered DSA tutor.

Frequently Asked Questions

What coding problems does Morgan Stanley ask in interviews?add

Morgan Stanley has been reported to ask 49 distinct coding problems. The most common topics are array, string, dynamic-programming. 13 are Easy difficulty, 28 are Medium, and 8 are Hard. Problems are sorted by frequency - the ones at the top are asked most often.

How hard are Morgan Stanley coding interviews?add

Based on 49 reported problems, Morgan Stanley interviews are in line with industry averages - 16% Hard vs 18% overall. 57% of questions are Medium difficulty. Focus on the high-frequency Medium problems first, then work through the Hard ones.

How should I prepare for a Morgan Stanley coding interview?add

Start with the highest-frequency problems listed on this page. Focus on the core topics: array, string, dynamic-programming. Practice solving them under time pressure and explaining your approach out loud. Mock interviews with AI can simulate the real experience.

Other companies to explore

Ready to ace your Morgan Stanley interview?

Simulate a real Morgan Stanley coding interview with an AI interviewer. Get a scorecard with specific feedback on your problem-solving, code quality, and communication.

Simulate a Morgan Stanley interview with AIarrow_forward