Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

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

Morgan Stanley

4 rounds | 10 Coding
problems

Journey

Hello team, my name is Jay here i would like to share my interview journey experience with Morgan Stanley, hope this information willl useful in your careers. So i was working in service based company from last 3.5 years and now i wanted to switch in some product based company, so i started looking for new job from linkedin, Naukri and many other sites and I applied in mostly big mnc product based company but in some of the company i got rejection mail so at the last i got mail from Morgan Stanley and they scheduled my interview.

Application story

i wanted to switch in some product based company, so i started looking for new job from linkedin, Naukri and many other sites and I applied in mostly big mnc product based company but in some of the company i got rejection mail so at the last i got mail from Morgan Stanley and they scheduled my interview.

Why selected/rejected for the role?

There was 4 round of interview, 3 round consists of coding round and problem solving skills and last round was hr round, I passed all round and later I got offer letter.

Preparation

Duration: 4 months

Topics: Data structures and algorithms,System design, operating system, DBMS

Tip

Tip 1 : do atleast some project for what topic you prepared

Application process

Where: Campus

Eligibility: No

Resume tip

Tip 1: don't put wrong things

Tip 2: keep your resume short

01

Round

Medium

Online Coding Test

Duration25 minutes

Interview date13 Mar 2023

Coding problem3

It was my 1st round and this round of data structures and algorithms code

```
[1, 2, 3, 4] is a strictly increasing array, while [2, 1, 4, 3] is not.
```

Problem approach

Step 1: Create an array dp of size n, where dp[i] will represent the length of the longest increasing subsequence ending at index i.

Step 2: Initialize all the values in the dp array to 1.

Step 3: Iterate through the array from left to right. For each index i, iterate through all the indices from 0 to i-1. If arr[j] < arr[i], then update dp[i] as max(dp[i], dp[j]+1). Finally, return the maximum value in the dp array.

```
1. A ‘path’ is a sequence of adjacent pair nodes with an edge between them in the binary tree.
2. The ‘path’ doesn’t need to pass through the root.
3. The ‘path sum’ is the sum of the node’s data in that path.
```

Problem approach

DSA Medium Practice Problems

Naman Shah

Tell me 3 dsa medium question and provide 3 steps shot solution

Sure, here are three DSA medium-level questions along with their solutions:

Question 1: Given an array of integers, find the length of the longest increasing subsequence.

Solution:

Step 1: Create an array dp of size n, where dp[i] will represent the length of the longest increasing subsequence ending at index i.

Step 2: Initialize all the values in the dp array to 1.

Step 3: Iterate through the array from left to right. For each index i, iterate through all the indices from 0 to i-1. If arr[j] < arr[i], then update dp[i] as max(dp[i], dp[j]+1). Finally, return the maximum value in the dp array.

Question 2: Given a binary tree, find the maximum path sum. A path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections.

Solution:

Step 1: Define a recursive function maxPathSumHelper(node), which returns the maximum path sum that can be obtained starting from the given node.

Step 2: In the maxPathSumHelper function, recursively call the function for the left and right children of the node.

Step 3: Calculate the maximum path sum passing through the current node as max(node.val, node.val + left_sum + right_sum), where left_sum and right_sum are the maximum path sums obtained from the left and right subtrees, respectively.

Step 4: Update a global variable max_sum with the maximum path sum obtained so far.

```
str = "ababc"
The longest palindromic substring of "ababc" is "aba", since "aba" is a palindrome and it is the longest substring of length 3 which is a palindrome.
There is another palindromic substring of length 3 is "bab". Since starting index of "aba" is less than "bab", so "aba" is the answer.
```

Problem approach

Step 1: Create a two-dimensional boolean array dp of size n x n, where dp[i][j] will represent whether the substring from index i to index j is a palindrome or not.

Step 2: Initialize all the values in the dp array to false.

Step 3: Iterate through the string from right to left, and for each index i, iterate through all the indices from i to n-1. If s[i] == s[j] and j-i < 2 or dp[i+1][j-1] == true, then set dp[i][j] to true.

Step 4: Keep track of the longest palindromic substring found so far, and return it at the end.

02

Round

Medium

Online Coding Test

Duration30 minutes

Interview date13 Mar 2023

Coding problem3

This was 2nd round of interview and it was some hard level of dsa questions.

```
1. push(data) :
This function should take one argument of type integer. It pushes the element into the stack and returns nothing.
2. pop() :
It pops the element from the top of the stack and returns nothing.
3. top() :
It returns the element being kept at the top of the stack.
4. getMin() :
It returns the smallest element present in the stack.
```

```
Query-1(Denoted by an integer 1): Pushes integer data to the stack. (push function)
Query-2(Denoted by an integer 2): Pops the data kept at the top of the stack. (pop function)
Query-3(Denoted by an integer 3): Fetches and returns the data being kept at the top of the stack. (top function)
Query-4(Denoted by an integer 4): Returns the smallest element present in the stack. (getMin() function)
```

Problem approach

Step 1: Use a linked list to implement the stack.

Step 2: Keep track of the minimum value using a separate variable that gets updated during push() and pop() operations.

```
Input : 1 -> 2 -> 3 -> 4 -> 'NULL' and 'K' = 2
Output: 1 -> 2 -> 4 -> 'NULL'
Explanation:
After removing the second node from the end, the linked list become 1 -> 2 -> 4 -> 'NULL'.
```

Problem approach

Step 1: Traverse the linked list to get its length.

Step 2: Traverse the list again, stopping at the (length-N+1)th node, and remove the Nth node from the end.

```
1. A binary tree is a tree in which each node can have at most two children.
2. The given tree will be non-empty i.e the number of non-NULL nodes will always be greater than or equal to 1.
3. Multiple nodes in the tree can have the same values, all values in the tree will be positive.
```

Problem approach

Step 1: Define a recursive function that takes a node as input.

Step 2: Traverse the tree recursively, keeping track of whether each node is a left or right child of its parent. If a node is a left child and has no children of its own, add its value to the sum.

03

Round

Hard

Online Coding Test

Duration40 minutes

Interview date14 Mar 2023

Coding problem3

This was my 3rd round and it has question from system design and Operating system

Design a distributed key-value store that can handle millions of requests per second.

Problem approach

Step 1: Use a hash function to shard the keys across multiple servers.

Step 2: Use a distributed consensus protocol like Paxos or Raft to ensure consistency across the nodes.

Implement a deadlock detection algorithm for a resource allocation system with multiple processes and resources.

Problem approach

Step 1: Build a graph where each process is a node, and each resource is a node.

Step 2: Use a cycle detection algorithm to find cycles in the graph.

Design a distributed system for real-time analytics of streaming data.

Problem approach

Step 1: Use a distributed messaging system like Kafka or RabbitMQ to ingest and buffer the streaming data.

Step 2: Use a distributed computing framework like Spark or Flink to process the data in real-time.

Step 3: Use a distributed database like Cassandra or HBase to store the processed data for later analysis.

04

Round

Easy

HR Round

Duration20 minutes

Interview date14 Mar 2023

Coding problem1

This was my final round and it was hr round.

Can you describe a situation where you had to make a difficult technical decision and how you arrived at your final solution?

Here's your problem of the day

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

Suppose list1 is [2, 133, 12, 12], what is max(list1) in Python?

Choose another skill to practice

Start a Discussion

Similar interview experiences

SDE - 2

3 rounds | 3 problems

Interviewed by Morgan Stanley

1918 views

0 comments

0 upvotes

Technology Analyst

2 rounds | 3 problems

Interviewed by Morgan Stanley

797 views

0 comments

0 upvotes

SDE - 2

4 rounds | 10 problems

Interviewed by Morgan Stanley

1275 views

0 comments

0 upvotes

Technology Analyst Intern

3 rounds | 6 problems

Interviewed by Morgan Stanley

18 views

0 comments

0 upvotes

Companies with similar interview experiences

SDE - 2

5 rounds | 12 problems

Interviewed by Walmart

23703 views

8 comments

0 upvotes

SDE - 2

3 rounds | 4 problems

Interviewed by HashedIn

7927 views

0 comments

0 upvotes

SDE - 2

3 rounds | 5 problems

Interviewed by Amazon

5117 views

0 comments

0 upvotes