Morgan Stanley interview experience Real time questions & tips from candidates to crack your interview

Technology Analyst

Morgan Stanley
upvote
share-icon
4 rounds | 11 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 6 months
Topics: Data Structures, Algorithms, System Design, Aptitude, OOPS
Tip
Tip

Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.

Application process
Where: Campus
Eligibility: Above 7 CGPA
Resume Tip
Resume tip

Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.

Interview rounds

01
Round
Medium
Face to Face
Duration60 minutes
Interview date16 Apr 2015
Coding problem3

Technical Interview round with questions based on DSA, Output Prediction etc.

1. Find The Repeating And Missing Number

Easy
10m average time
90% success
0/40
Asked in companies
AmazonSamsungPhonePe

You are given an array 'nums' consisting of first N positive integers. But from the N integers, one of the integers occurs twice in the array, and one of the integers is missing. You need to determine the repeating and the missing integer.

Example:
Let the array be [1, 2, 3, 4, 4, 5]. In the given array ‘4’ occurs twice and the number ‘6’ is missing.
Problem approach

XOR approach can be used to solve this question in an efficient manner. 
The following property of XOR can be used :
1. If x1^x2^…xn = a and x1^x2^..xn-1 = b , then a^b = xn
Steps:
1. Declare two variables a= 0 and b = 0
2. Calculate the xor of numbers from 1 to n and store them in a i.e. 1^2^…n = a. 
3. Now traverse the array from start to end.
4. For every index i update b as b = b ^ arr[i]
5. Return the missing number as a ^ b. 
Time Complexity : O(N)
Space complexity : O(1)

Try solving now

2. Implement Atoi Function

Hard
10m average time
90% success
0/120
Asked in companies
AmazonAdobeMorgan Stanley

You are given a string ‘s’ of length 'n'.


Implement the atoi(string s) function, which converts a given string into a 32-bit signed integer, following similar principles as the atoi function in C/C++.


Here's the step-by-step algorithm for myAtoi(string s):


1. Discard any leading whitespaces.


2. If the next character (if not at the end of the string) is '-' or '+', consider it to determine the sign of the result. If neither is present, assume the result is positive.


3. Read and accumulate digits until a non-digit character is encountered or the end of the input is reached.


4. Convert the collected digits into an integer (e.g., "123" becomes 123, "0032" becomes 32). If no digits were read, the integer is 0. Adjust the sign as needed (as determined in step 2).


5. If the integer falls outside the range of a 32-bit signed integer [-2^31, 2^31 - 1], constrain it to stay within the range. For instance, if the integer is less than -2^31, set it to -2^31; if it's greater than 2^31 - 1, set it to 2^31 - 1.


6. Return the resulting integer.


Note :
1. Only the space character ' ' is treated as a whitespace.

2. All characters other than leading whitespace or digits are considered.


Example:
Input: 45rohit12

Output: 45

Explanation: 
Leading Whitespace: Leading whitespace characters (" ") are ignored.

Numeric Portion: The numeric portion starts with the digit "4".

Reading Numeric Characters: The algorithm reads "4" and "5" to form "45".

End of Numeric Portion: The numeric portion ends at "r", non-numeric characters are skipped.

Parsing Result: "45" is parsed into the integer value 45, the final result.
Problem approach

The idea is to use the ASCII value of the digits from 0 to 9 start from 48 – 57.
Therefore, to change the numeric character to an integer subtract 48 from the ASCII value of the character will give the corresponding digit for the given character.

Pseudocode :
convert(string s) 

// Initialize a variable 
num = 0; 
for (i=0 to length of string) 

// Subtract 48 from the current digit 
num = num * 10 + (int(s[i]) - 48); 

// Print the answer 
print(num) 
}

Try solving now

3. Palindrome Partitioning

Moderate
25m average time
75% success
0/80
Asked in companies
CultfitDunzoQuikr

You are given a string 'S'. Your task is to partition 'S' such that every substring of the partition is a palindrome. You need to return all possible palindrome partitioning of 'S'.

Note: A substring is a contiguous segment of a string.

For Example:
For a given string “BaaB”
3 possible palindrome partitioning of the given string are:
{“B”, “a”, “a”, “B”}
{“B”, “aa”, “B”}
{“BaaB”}
Every substring of all the above partitions of “BaaB” is a palindrome.
Problem approach

The problem can be solved using recursion. If the given string is a palindrome, 0 cuts are needed. Otherwise, try making cuts at all possible positions and calculate the cost for each cut recursively and take the minimum of all costs. 

// i is the starting index and j is the ending index. 
Initially, i=0 and j=n-1
minCuts(str, i, j) = 0 if i == j // When string is of length 1.
minCuts(str, i, j) = 0 if str[i..j] is palindrome.

// If the above conditions are not true, then minimum cuts needed can be calculated recursively using the following formula.
minCuts(str, i, j) = min { minCuts(str, i, k) + 1 + minCuts(str, k+1, j) } 
where k varies from i to j-1

The above approach can be optimized using dynamic programming. A 2-d array can be used to store the intermittent results calculated in recursive functions. 
The time complexity of this approach would be O(N^3).

Try solving now
02
Round
Medium
Face to Face
Duration60 minutes
Interview date16 Apr 2015
Coding problem6

This was a technical interview round with 2 interviewers. Questions based on DSA, OOPS , DBMS were asked.

1. Height of the Binary Tree

Moderate
10m average time
90% success
0/80
Asked in companies
Morgan StanleyAmazonSymphony Talent, LLC

You have been given the Inorder Traversal and Level Order Traversal of a Binary Tree of integers. Your task is to calculate the height of the Binary tree without constructing it.

The height of the binary tree is the number of edges in the longest path from the root node to any leaf node in the tree. In case the tree has only one node, the height is taken to be 0.

Problem approach

The idea is to recursively calculate height of left and right subtrees of a node and assign height to the node as max of the heights of two children plus 1. 

Algorithm: 
maxDepth()
1. If tree is empty then return -1
2. Else
(a) Get the max depth of left subtree recursively i.e., call maxDepth( tree->left-subtree)
(a) Get the max depth of right subtree recursively i.e., call maxDepth(tree->right-subtree)
(c) Get the max of max depths of left and right subtrees and add 1 to it for the current node.
max_depth = max(max dept of left subtree, max depth of right subtree) + 1
(d) Return max_depth

Try solving now

2. Cycle Detection In Undirected Graph

Moderate
0/80
Asked in companies
AmazonAdobeSamsung

You have been given an undirected graph with 'N' vertices and 'M' edges. The vertices are labelled from 1 to 'N'.

Your task is to find if the graph contains a cycle or not.

A path that starts from a given vertex and ends at the same vertex traversing the edges only once is called a cycle.

Example :

In the below graph, there exists a cycle between vertex 1, 2 and 3. 

Example

Note:

1. There are no parallel edges between two vertices.

2. There are no self-loops(an edge connecting the vertex to itself) in the graph.

3. The graph can be disconnected.

For Example :

Input: N = 3 , Edges =  [[1, 2], [2, 3], [1, 3]].
Output: Yes

Explanation : There are a total of 3 vertices in the graph. There is an edge between vertex 1 and 2, vertex 2 and 3 and vertex 1 and 3. So, there exists a cycle in the graph. 
Problem approach

DFS can be used to detect cycle in an undirected graph. Do a DFS traversal of the given graph. For every visited vertex ‘v’, if there is an adjacent ‘u’ such that u is already visited and u is not parent of v, then there is a cycle in graph.
If we don’t find such an adjacent for any vertex, we say that there is no cycle.
Pseudocode :

DetectCycle(graph, v, visited[], parent)
{
// mark the current node as visited
visited[v] = true;
// do for every edge (v, w)
for (w: graph[v])
{
// if `w` is not visited yet
if (!visited[w])
{
if (DetectCycle(graph, w, visited, v)) {
return true;
}
}
// if `w` is visited, and `w` is not a parent
else if (w != parent)
{
// back-edge (cycle) found
return true;
}

// No back-edges were found in the graph
return false;
}

Try solving now

3. DBMS Question

Write a SQL query to multiply two matrices.

Problem approach

Assuming the following structure:

A (row INT, col INT, value FLOAT)
B (row INT, col INT, value FLOAT)

You can write this:

SELECT A.row, B.col, SUM(A.value * B.value)
FROM A JOIN B ON A.col = B.row
GROUP BY A.row, B.col

4. OOPS Question

Can a constructor be virtual?

Problem approach

In C++, the constructor cannot be virtual, because when a constructor of a class is executed there is no virtual table in the memory, means no virtual pointer defined yet. So, the constructor should always be non-virtual.

5. OOPS Question

Can a destructor be virtual?

Problem approach

Yes, it is possible to have pure virtual destructor. Pure virtual destructors are legal in standard C++ and one of the most important things to remember is that if a class contains a pure virtual destructor, it must provide a function body for the pure virtual destructor.

6. OOPS Question

Can a constructor be private in C++?

Problem approach

By default, constructors are defined in public section of class. But yes, Constructor can be defined in private section of class

03
Round
Medium
Group Discussion
Duration45 minutes
Interview date16 Apr 2015
Coding problem1

This was a group activity round where we were divided in group of 3 and 4. 8 or 9 panelists were watching us.

1. Group Discussions

We were given a list of servers databases and client systems having pros and cons. We were asked to choose the best possible combination that suits all client requirements.

04
Round
Easy
HR Round
Duration30 minutes
Interview date16 Apr 2015
Coding problem1

HR round with typical behavioral problems.

1. Basic HR Questions

1. Tell something about yourself
2. Greatest achievement in your life
3. Achievements of others that you like
4. The interviewer then gave me a scenario like you are team leader and you have to instruct your team to deliver blood from blood bank to hospital very fast as someone's life is in danger..
5. Then he asked me If I was a team player?
6. He was like what you do to motivate your team as a leader and how would you make your team perform best?
7. Do you want to ask some thing to me?
 

Problem approach

Tip 1 : Be sure to do your homework on the organization and its culture before the interview.
Tip 2 : Employers want to understand how you use your time and energy to stay productive and efficient. Be sure to emphasize that you adhere to deadlines and take them seriously.
Tip 3 : Talk about a relevant incident that made you keen on the profession you are pursuing and follow up by discussing your education.

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

How do you remove whitespace from the start of a string?

Choose another skill to practice
Similar interview experiences
company logo
Technology Analyst
5 rounds | 13 problems
Interviewed by Morgan Stanley
932 views
0 comments
0 upvotes
company logo
Technology Analyst
3 rounds | 7 problems
Interviewed by Morgan Stanley
5103 views
0 comments
0 upvotes
company logo
Technology Analyst
2 rounds | 3 problems
Interviewed by Morgan Stanley
1433 views
0 comments
0 upvotes
company logo
Technology Analyst
2 rounds | 6 problems
Interviewed by Morgan Stanley
982 views
0 comments
0 upvotes